F
Fortepianissimo
I can lock a file using the following snippet:
---
import fcntl
f=open('flock.txt','w')
fcntl.lockf(f.fileno(),fcntl.LOCK_EX)
---
If some other script tries to open 'flock.txt', it'll wait until the
file is unlocked/closed.
My question is, I'd like to tell a script to quit *immediately* if it
cannot open the file, or, if it knows the file is locked.
The reason I need this is I want to serialize parallel processes using
a lock file. Any suggestion is welcome!
---
import fcntl
f=open('flock.txt','w')
fcntl.lockf(f.fileno(),fcntl.LOCK_EX)
---
If some other script tries to open 'flock.txt', it'll wait until the
file is unlocked/closed.
My question is, I'd like to tell a script to quit *immediately* if it
cannot open the file, or, if it knows the file is locked.
The reason I need this is I want to serialize parallel processes using
a lock file. Any suggestion is welcome!