How do I force a single instance of a python app?

Mark Hammond MarkH at ActiveState.com
Thu Oct 26 19:05:01 EDT 2000


<jay.krell at cornell.edu> wrote in message
news:mailman.972547429.774.python-list at python.org...

> >Or attempt to create a directory - that is an atomic operation that
> >indicates what you need to know.  Obviously will need some sort of
>
...
>
> Creating a directory does not have automatic cleanup upon process
death.

That is exactly what I said (in a round-about way) in the sentence
that starts with "Obviously..." quoted above.  You must have missed
the original?

> A real Win32 synchronization mechanism like a possibly named mutex
is best,

I thought a Win32 specific solution was ruled out?

> but for the people that insist on files, use the Win32 api that lets
you
> specify no sharing.

If people are happy with using a Win32 specific solution, but insist
on using files when other Win32 facilities better suited exist, they
are fools ;-)

The idea of creating a directory was one I saw in a very old source
control system.  They documented that they used a directory as a lock,
as it was the only reasonable, cross platform, atomic operation with
failure they could rely on.  If a Windows only solution is acceptable,
then this thread has already covered the best answer...

Mark.





More information about the Python-list mailing list