Singleton process
Andrew Bennetts
andrew-pythonlist at puzzling.org
Mon Dec 22 01:46:24 EST 2003
[Please don't top-post]
On Mon, Dec 22, 2003 at 01:38:27AM -0500, Benjamin Han wrote:
> On Mon, 22 Dec 2003, Jp Calderone wrote:
[...]
> > import os, errno
> >
> > def shouldRun():
> > try:
> > os.mkdir(MAGIC_PATH)
> > except OSError, e:
> > if e.args[0] == errno.EEXIST:
> > return False
> > raise
> > return True
>
> But this solution creates a file race condition?
How? mkdir is atomic. Either it creates the directory and succeeds, or it
fails. I don't see any problems here.
-Andrew.
More information about the Python-list
mailing list