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

Donn Cave donn at u.washington.edu
Thu Oct 26 11:41:39 EDT 2000


Quoth Dale Strickland-Clark <dale at out-think.NOSPAMco.uk>:
| "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.

Normal, correct results for C library stdio, which is the basis for
the Python file object.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list