diff --git a/planet/http.py b/planet/http.py index d43e2e38..e02bc604 100644 --- a/planet/http.py +++ b/planet/http.py @@ -282,6 +282,12 @@ async def alog_response(*args, **kwargs): self._limiter = _Limiter(rate_limit=RATE_LIMIT, max_workers=MAX_ACTIVE) self.outcomes: Counter[str] = Counter() + self._loop: asyncio.AbstractEventLoop = None # type: ignore + + def _init_loop(self): + if self._loop: + return + # create a dedicated event loop for this httpx session. def _start_background_loop(loop): asyncio.set_event_loop(loop) @@ -294,6 +300,7 @@ def _start_background_loop(loop): self._loop_thread.start() def _call_sync(self, f: Awaitable[T]) -> T: + self._init_loop() return asyncio.run_coroutine_threadsafe(f, self._loop).result() @classmethod diff --git a/pyproject.toml b/pyproject.toml index bf915176..59ef0923 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "planet" authors = [{ name = "Planet", email = "python-sdk-contributors@planet.com" }] description = "Planet SDK for Python" dependencies = [ - "click>=8.0", + "click (>=8.0,!=8.2.1)", "geojson", "httpx>=0.28.0", "jsonschema",