mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Fix Windows exclusive lock test
This commit is contained in:
@@ -20,10 +20,21 @@ def exclusive_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)
|
||||||
|
flags = portalocker.LockFlags.EXCLUSIVE
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
lock = portalocker.Lock(str(path), mode="a+b")
|
lock = portalocker.Lock(
|
||||||
|
str(path),
|
||||||
|
mode="r+b",
|
||||||
|
flags=flags,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
lock = portalocker.Lock(str(path), mode="a+b", timeout=timeout)
|
lock = portalocker.Lock(
|
||||||
|
str(path),
|
||||||
|
mode="r+b",
|
||||||
|
timeout=timeout,
|
||||||
|
flags=flags,
|
||||||
|
)
|
||||||
with lock as fh:
|
with lock as fh:
|
||||||
yield fh
|
yield fh
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user