diff --git a/githubkit/throttling.py b/githubkit/throttling.py index 0388dc762..2d56eaf98 100644 --- a/githubkit/throttling.py +++ b/githubkit/throttling.py @@ -35,9 +35,15 @@ async def async_acquire(self, request: httpx.Request) -> AsyncGenerator[None, An class LocalThrottler(BaseThrottler): def __init__(self, max_concurrency: int) -> None: self.max_concurrency = max_concurrency - self.semaphore = threading.Semaphore(max_concurrency) + self._semaphore: Optional[threading.Semaphore] = None self._async_semaphore: Optional[anyio.Semaphore] = None + @property + def semaphore(self) -> threading.Semaphore: + if self._semaphore is None: + self._semaphore = threading.Semaphore(self.max_concurrency) + return self._semaphore + @property def async_semaphore(self) -> anyio.Semaphore: if self._async_semaphore is None: