how to keep one instance???
Jeff Epler
jepler at unpythonic.net
Tue May 18 12:37:49 EDT 2004
On Tue, May 18, 2004 at 02:52:51PM +0200, Heiko Wundram wrote:
> Am Dienstag, 18. Mai 2004 14:46 schrieb Jeff Epler:
> > Note that there are often race conditions here---if two copies of the
> > application start nearly simultaneously, both may detect that no
> > other copy of the app exists. If someone wants to tell me the way to
> > get this right in the context of Unix/X11, please speak up!
>
> Lock files in /tmp? Simply do file-based locking the daemon PID-file style...
> If you need code (which is race-free) to handle this, mail me, and I'll
> gladly send it to you.
X presents some different challenges from making sure only one instance
of a daemon is running. It mostly boils down to this:
I should be able to run one instance of an application *per display*,
not per machine, per user, or per home directory.
Take openoffice for instance. Right now, I have an instance of
openoffice running in a vnc session displaying a spreadsheet
(DISPLAY=:1). If I run "DISPLAY=:0 oowrite", I'll be very surprised to
see that a new window has actually been opened in the vnc session, not
on the display I asked for.
But "one instance of an application *per display*" is not quite right
either. Metadata (bookmarks) and data (documents) exist on filesystems.
So I should also be able to run one copy of oowrite on a machine with
home directory A, and one copy with home directory B. So maybe the
right thing is "one instance of an application per (display,
home-directory) pair"?
That leaves determining the canonical name for a particular display, I
guess, then using a normal lockfile approach...
Jeff
More information about the Python-list
mailing list