File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -1019,11 +1019,14 @@ def make_transport(options: Dict[str, Any]) -> Optional[Transport]:
10191019 use_http2_transport = options .get ("_experiments" , {}).get ("transport_http2" , False )
10201020 use_async_transport = options .get ("_experiments" , {}).get ("transport_async" , False )
10211021 # By default, we use the http transport class
1022- if use_async_transport and asyncio .get_running_loop () is not None :
1023- transport_cls : Type [Transport ] = AsyncHttpTransport
1024- else :
1025- use_http2 = use_http2_transport
1026- transport_cls = Http2Transport if use_http2 else HttpTransport
1022+ if use_async_transport :
1023+ try :
1024+ asyncio .get_running_loop ()
1025+ transport_cls : Type [Transport ] = AsyncHttpTransport
1026+ except RuntimeError :
1027+ # No event loop running, fall back to sync transport
1028+ logger .warning ("No event loop running, falling back to sync transport." )
1029+ transport_cls = Http2Transport if use_http2_transport else HttpTransport
10271030
10281031 if isinstance (ref_transport , Transport ):
10291032 return ref_transport
You can’t perform that action at this time.
0 commit comments