-
-
Notifications
You must be signed in to change notification settings - Fork 128
Bug: Reentrant behavior does not work with distinct lock objects on the same thread #282
Copy link
Copy link
Closed
Labels
Description
Setup
- Python 3.11.3
- filelock 3.12.4
- MacOS
Actual:
➜ python
>>> from filelock import FileLock
>>> lock_1 = FileLock("test.lock")
>>> lock_2 = FileLock("test.lock")
>>> lock_1.acquire()
<filelock._api.AcquireReturnProxy object at 0x100baa550>
>>> lock_1._context
ThreadLocalFileContext(lock_file='test.lock', timeout=-1, mode=420, lock_file_fd=3, lock_counter=1)
>>> lock_2._context
ThreadLocalFileContext(lock_file='test.lock', timeout=-1, mode=420, lock_file_fd=None, lock_counter=0)
>>> lock_2.acquire()
... hangsAlso it does not appear that releasing the lock removes the lock file (not sure if this is expected):
>>> from filelock import FileLock
>>> lock = FileLock("test.lock")
>>> lock.acquire()
<filelock._api.AcquireReturnProxy object at 0x102ad80d0>
>>> lock.release()➜ ls
test.lockExpectation:
lock_2can be acquired since it is locking the same file on the same thread per reentrancy definition in docs:
The lock objects are recursive locks, which means that once acquired, they will not block on successive lock requests
Reactions are currently unavailable