From c05123c63801a77e2ee7bbba59077aacae025baa Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 30 Jun 2025 14:43:37 -0400 Subject: [PATCH] Fix shared_lock timeout handling --- src/utils/file_lock.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/utils/file_lock.py b/src/utils/file_lock.py index 5ffba52..8df6031 100644 --- a/src/utils/file_lock.py +++ b/src/utils/file_lock.py @@ -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