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):
282
282
self ._limiter = _Limiter (rate_limit = RATE_LIMIT , max_workers = MAX_ACTIVE )
283
283
self .outcomes : Counter [str ] = Counter ()
284
284
285
+ self ._loop : asyncio .AbstractEventLoop = None # type: ignore
286
+
287
+ def _init_loop (self ):
288
+ if self ._loop :
289
+ return
290
+
285
291
# create a dedicated event loop for this httpx session.
286
292
def _start_background_loop (loop ):
287
293
asyncio .set_event_loop (loop )
@@ -294,6 +300,7 @@ def _start_background_loop(loop):
294
300
self ._loop_thread .start ()
295
301
296
302
def _call_sync (self , f : Awaitable [T ]) -> T :
303
+ self ._init_loop ()
297
304
return asyncio .run_coroutine_threadsafe (f , self ._loop ).result ()
298
305
299
306
@classmethod
You can’t perform that action at this time.
0 commit comments