mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 15:28:44 +00:00
Fix shared_lock timeout handling
This commit is contained in:
@@ -41,9 +41,19 @@ def shared_lock(
|
||||
path = Path(path)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.touch(exist_ok=True)
|
||||
lock = portalocker.Lock(
|
||||
str(path), mode="r+b", timeout=timeout, flags=portalocker.LockFlags.SHARED
|
||||
)
|
||||
if timeout is None:
|
||||
lock = portalocker.Lock(
|
||||
str(path),
|
||||
mode="r+b",
|
||||
flags=portalocker.LockFlags.SHARED,
|
||||
)
|
||||
else:
|
||||
lock = portalocker.Lock(
|
||||
str(path),
|
||||
mode="r+b",
|
||||
timeout=timeout,
|
||||
flags=portalocker.LockFlags.SHARED,
|
||||
)
|
||||
with lock as fh:
|
||||
fh.seek(0)
|
||||
yield fh
|
||||
|
Reference in New Issue
Block a user