zhechen-cs opened a new issue, #2202:
URL: https://github.com/apache/libcloud/issues/2202
## Summary
`LockLocalStorage.__enter__()` leaves its thread lock acquired if the IPC
lock times out or raises an exception. Since a failed `__enter__` does not call
`__exit__`, reusing the same lock object cannot acquire the thread lock again,
even after the IPC contention is gone.
## Detailed Information
Reproduced on current `trunk` (`bd9cbb3e393bc42f57684481e7c62e9293007584`),
Python 3.12/macOS. This deterministic reproducer models the documented false
return from `fasteners.InterProcessLock.acquire()` when its timeout expires:
```python
import os
import tempfile
from unittest.mock import patch
from libcloud.storage.drivers.local import LockLocalStorage
from libcloud.common.types import LibcloudError
with tempfile.TemporaryDirectory() as root:
lock = LockLocalStorage(os.path.join(root, "object"))
with patch.object(lock.ipc_lock, "acquire", return_value=False):
try:
lock.__enter__()
except LibcloudError:
pass
print(lock.thread_lock.locked()) # True
```
The thread lock should be released before propagating acquisition failure.
The same leak occurs if IPC acquisition raises `OSError` or is interrupted by
`KeyboardInterrupt`.
This is separate from #1975 / #2172, which address leftover lock files after
a successful acquisition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]