File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,12 @@ async def alog_response(*args, **kwargs):
282282 self ._limiter = _Limiter (rate_limit = RATE_LIMIT , max_workers = MAX_ACTIVE )
283283 self .outcomes : Counter [str ] = Counter ()
284284
285+ self ._loop : asyncio .AbstractEventLoop = None # type: ignore
286+
287+ def _init_loop (self ):
288+ if self ._loop :
289+ return
290+
285291 # create a dedicated event loop for this httpx session.
286292 def _start_background_loop (loop ):
287293 asyncio .set_event_loop (loop )
@@ -294,6 +300,7 @@ def _start_background_loop(loop):
294300 self ._loop_thread .start ()
295301
296302 def _call_sync (self , f : Awaitable [T ]) -> T :
303+ self ._init_loop ()
297304 return asyncio .run_coroutine_threadsafe (f , self ._loop ).result ()
298305
299306 @classmethod
You can’t perform that action at this time.
0 commit comments