mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Fix shared_lock timeout handling
This commit is contained in:
@@ -41,8 +41,18 @@ def shared_lock(
|
|||||||
path = Path(path)
|
path = Path(path)
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
path.touch(exist_ok=True)
|
path.touch(exist_ok=True)
|
||||||
|
if timeout is None:
|
||||||
lock = portalocker.Lock(
|
lock = portalocker.Lock(
|
||||||
str(path), mode="r+b", timeout=timeout, flags=portalocker.LockFlags.SHARED
|
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:
|
with lock as fh:
|
||||||
fh.seek(0)
|
fh.seek(0)
|
||||||
|
Reference in New Issue
Block a user