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

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Thu Oct 26 06:05:55 EDT 2000


"Joshua Muskovitz" <josh at open.com> wrote:

>"Dale Strickland-Clark" <dale at out-think.NOSPAMco.uk> wrote in message
>news:urodvssp7e7cmbv1ljlqnqgej9rjhfqbli at 4ax.com...
>> Open a flag file exclusively for writing. If successful you are alone,
>> if not, another instance already has the file.
>>
>> The OS should close the file and free the exclusive lock if the app
>> crashes.
>
>This would be great, but on my Win2k box, I can open up the same file for
>write in two separate Python instances at the same time.  :-(
>
>The second instance of open("foo","w") does not fail.
>

This is pretty naf, isn't it. I get the same. 

I can even open for append from two different instances of the same
program and get interleaved output. 

Does this occur with other languages/libraries?  I haven't tested it
but I can't help wondering if Python is using inappropriate options
when opening output files.
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants





More information about the Python-list mailing list