File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments