Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions planet/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down