Singleton process

Cameron Laird claird at lairds.com
Tue Dec 23 03:40:49 CET 2003


In article <mailman.61.1072141579.684.python-list at python.org>,
Andrew Bennetts  <andrew-pythonlist at puzzling.org> wrote:
			.
			.
			.
>mkdir has the advantage of being fairly simple, although it does feel a bit
>hackish, because that's not what directories are meant to be used for.
>
>Slightly cleaner would be to use os.open with the O_CREAT and O_EXCL flags,
>I think.  I'm not sure what the portability of those flags is, though --
>whereas creating directories is supported on most platforms I can think of
>:)
>
>> Here's how I think about this:  what does the OS itself manage
>> as a process-referring singleton?  Socket service!  Only one
>> server can be on a port at a time; that's exactly the expressed
>> requirement.
>
>Sure, but the OS also ensures that only one file/directory can be at a
>particular path at any given time, so that's fine too.  Sockets do have the
>advantage of being automatically cleaned up when the process exits -- sort
>of.  SO_REUSEADDR is probably good enough to get the behaviour you'd want,
>though.
			.
			.
			.
Right:  OSs certainly handle filesystems, but there's no
"cleanup", as with sockets.  Also, while O_EXCL and friends
are supposed to be portable, there are a lot of subtleties
to them--and even outright errors, when NFS is involved.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net




More information about the Python-list mailing list