Skip to content

Commit 1bd1e66

Browse files
committed
Merge branch 'mark/0.2.1' into 20-formal_review_020_-_021
basen on PR #21
2 parents 215c8e5 + 4ed9c7d commit 1bd1e66

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gh_tt/classes/gitter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Gitter(Lazyload):
2121
fetched = False # Flag to indicate if the repository has been fetched
2222
class_cache: ClassVar[dict] = {} # Dictionary to store class cache data
2323

24-
_fetch_lock = asyncio.Lock()
24+
_fetch_lock: ClassVar[asyncio.Lock | None] = None
2525

2626
git_path = shutil.which('git')
2727
assert git_path is not None, "Git not found on PATH. Git is required for gh-tt to work. To proceed, install git."
@@ -211,11 +211,18 @@ def get_commit_sha(cls):
211211
"""Get current commit SHA"""
212212
return asyncio.run(cls()._run("get_commit_sha"))
213213

214+
@classmethod
215+
def _get_fetch_lock(cls):
216+
"""Get or create the fetch lock lazily to ensure it's created in the correct event loop"""
217+
if cls._fetch_lock is None:
218+
cls._fetch_lock = asyncio.Lock()
219+
return cls._fetch_lock
220+
214221
@classmethod
215222
async def fetch(cls, *, prune=False, again=False):
216223
"""Fetch """
217224

218-
async with cls._fetch_lock:
225+
async with cls._get_fetch_lock():
219226
if cls.fetched and not again:
220227
return True
221228

0 commit comments

Comments
 (0)