Inhibiting duplicate apps in Windows?
Peter Hansen
peter at engcorp.com
Thu Jun 20 21:39:56 EDT 2002
More information about the Python-list mailing list
Thu Jun 20 21:39:56 EDT 2002
- Previous message (by thread): Inhibiting duplicate apps in Windows?
- Next message (by thread): Inhibiting duplicate apps in Windows?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chris Liechti wrote: > > "Edward K. Ream" <edream at tds.net> wrote in news:3D11F9E8.DFFFC8E4 at tds.net: > > What I would like is for the second copy of Leo to detect that another > > copy of leo.py is already running, send a message to the first copy and > > then exit. I wonder if anyone knows how this might be done? > dumb solution: create a "lock file" and remove it on programm exit. the > other problem is that you have to delete it manually when the app crashes > (i deleted may lock files with older Netscapes ;-) I wonder whether there's not a simple way to avoid manual deletion. If one application creates the lock file, it can hold it open as long as it is running. A second invocation can detect the first by its failure to open the same file for writing. If the file already exists, it can try to delete it with os.remove(). That should fail if the first application still has it open, but if the first application actually crashed, the OS should allow the file to be removed, at which point the new invocation can safely recreate it, knowing it now has the lock. Haven't actually tried this myself... :) -Peter
- Previous message (by thread): Inhibiting duplicate apps in Windows?
- Next message (by thread): Inhibiting duplicate apps in Windows?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list