getsomeual / pylockfile

Automatically exported from code.google.com/p/pylockfile
Other
0 stars 0 forks source link

Possible to release a file lock acquired by another pyhton process #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
> What steps will reproduce the problem?

All done from two interactive python interpreters

1. In terminal 1, print:
    lock = lockfile.FileLock('somefile')
    lock.acquire()

2. In terminal 2, print:
    lock = lockfile.FileLock('somefile')
    lock.acquire()

3. When interpreter 2 hangs waiting for the lock, issue a KeyboardInterrupt 
(Ctrl+C). Then print (in terminal 2):
    lock.release()

> What is the expected output? What do you see instead?

NotMyLock is not raised. The lock file is deleted by the 2nd python process, as 
well as the temporary file created by 2nd process. Trying to release the lock 
from the 1st process causes a NotLocked exception and leaves the temporary file 
created by the 1st process undeleted.

> What version of the product are you using? On what operating system?

lockfile-0.9.1, Python 2.7.1 on Mac OS X

> Please provide any additional information below.

This case is pretty artificial and probably difficult to face in real-life 
python programs. But it indicates a possible error in module's internals (I 
haven't been able to read the source code yet), since I was able to release a 
lock I hadn't actually acquired (by using the interrupt trick). 

Original issue reported on code.google.com by s.klevz...@gmail.com on 15 Apr 2011 at 3:11

GoogleCodeExporter commented 8 years ago
By the way, when FileLock is used in context-manager style in both processes, 
this issue is not reproduced. However, if you still call lock.release() 
manually in second process, the lock is deleted.

Original comment by s.klevz...@gmail.com on 15 Apr 2011 at 3:23