IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Python rocks, COM sucks
at least that's my opinion so far. Python has worked out well; it lets me get the job done without a lot of fuss.

Although the Python COM crew has done a good job, there are some weak spots. For example, there is no automatic generation of Type Libraries, which are necessary to use Python COM objects from C++, e.g. Borland C++ Builder.

Anyway, the more learn about COM, the less impressed I am. Still, at least it allows me to code in Python.

For the main programs, I will continue to use VB or BCB, since I need something I can insert ActiveX controls into (OK, I might be able to use PythonWin, but since it's a wrapper around MFC, I'd rather use VCL in BCB than MFC (PythonWin) in Python).

I am using Tkinter for creating dialogs in Python code. For example, I am working on Python/Tkinter code to create a settings dialog from an INI file. So far I'm pretty happy with Tkinter; it seems a good fit for the job. I refuse to PythonWin and wxWindows looks more complicated than what I need (it's based around a document / view model similar to MFC).

Some of my problems are due to "Windows-isms" (sorry, I mean 'Wonderful features in the most innovative piece of software ever'). For example, SetForegroundWindow works well in NT to make a Tkinter window the active window, but supposedly won't do that in W2K -- and there's no good way around it.

Tony
New Ah Window-isms
I'm having problems with the keystone of the American Way myself.

Anybody that knows a solution to this please let me know. It amounts to multiple processes accessing the same file. I am working in J-OAK. (OK Java to the rest of you). I am using:

public boolean createNewFile()
throws IOException

on which the Java Doc says:

"Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file. This method, in combination with the deleteOnExit() method, can therefore serve as the basis for a simple but reliable cooperative file-locking protocol.

Returns:
true if the named file does not exist and was successfully created; false if the named file already exists"

Although my experience seems to suggest that this operation is not atomic on Windows.

My second safety strategy involves the use of a class I wrote called AtomicFileWriter which writes the data to a tmp file until you close it, then renames the tmp file onto the desired file. On Unix this is the usual technique, on Windows, atomic renaming is not supported and I am forced to test the platform and, if Windows, delete the old file before doing the rename. Given that I do this after the creation of my lock file, and also given that I don't try to read or write unless I manage to obtain the lock, I would like to think that this should be pretty safe but I'm seeing oddities on Windows that lead me to believe the neither mechanism is sufficient.

Anybody got a better strategy for doing a shared process lock on Windows ? Someone has suggested using sockets on some port as a locking mechanism but I'm suspicious as I've seen instances where loopback networking didn't work when the machine was off the network and I don't want to make the program dependent on the existence of a network connection.


The average hunter gatherer works 20 hours a week.
The average farmer works 40 hours a week.
The average programmer works 60 hours a week.
What the hell are we thinking?
New Use a database?
Hmmm...you don't want sockets...

Would using [link|http://www.sleepycat.com/|BerkeleyDB] be acceptable? (There may be licensing issues with Java, you should check that.)

Cheers,
Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything."
--Richard Feynman
New From Java?
Too heavy and platform dependent I think
The average hunter gatherer works 20 hours a week.
The average farmer works 40 hours a week.
The average programmer works 60 hours a week.
What the hell are we thinking?
New AFAIK
They are only a few hundred K, and they are pretty darned portable.

Plus you can rip everything out but the locking subsystem if you want (which is implemented using shared memory regions - you could just peek then write it yourself).

Cheers,
Ben
"... I couldn't see how anyone could be educated by this self-propagating system in which people pass exams, teach others to pass exams, but nobody knows anything."
--Richard Feynman
     Python rocks, COM sucks - (tonytib) - (4)
         Ah Window-isms - (tuberculosis) - (3)
             Use a database? - (ben_tilly) - (2)
                 From Java? - (tuberculosis) - (1)
                     AFAIK - (ben_tilly)

For Wade, it is to laugh.
36 ms