Making sure script only runs once instance at a time.
Eric S. Johansson
esj at harvee.org
Tue Oct 3 15:50:11 CEST 2006
> Eric S. Johansson wrote:
>> the problem with this solution is that it does not handle the read
>> nonexclusive/write exclusive locking model. In this model, reads don't
>> block, they only register that the request is in process. writes lock
>> request block until all outstanding reads have completed. When there is
>> a write lock waiting, all subsequent reads lock requests block until the
>> write has completed.
> I should have said "lock file" -- I'm not trying to do file locking for
> concurrent access to a file; I'm trying to provide a lock file to
> determine if an instance of a process is already spawned.
That difference was clear to me and I appreciate your comment clarifying
the issue further.
I was trying to point out how there are more models of locking that we
could use in Python than the single point lock as you had described.
Unfortunately, most system locks are hard to get right and difficult to
test so you're never quite sure until something breaks and then you know
you did it wrong.
I really should grab the code you pasted and use it as a rewrite for
portalocker. Someday. <sigh>
More information about the Python-list