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 @@ -1021,11 +1021,14 @@ def make_transport(options: Dict[str, Any]) -> Optional[Transport]:
10211021 use_http2_transport = options .get ("_experiments" , {}).get ("transport_http2" , False )
10221022 use_async_transport = options .get ("_experiments" , {}).get ("transport_async" , False )
10231023 # By default, we use the http transport class
1024- if use_async_transport and asyncio .get_running_loop () is not None :
1025- transport_cls : Type [Transport ] = AsyncHttpTransport
1026- else :
1027- use_http2 = use_http2_transport
1028- transport_cls = Http2Transport if use_http2 else HttpTransport
1024+ if use_async_transport :
1025+ try :
1026+ asyncio .get_running_loop ()
1027+ transport_cls : Type [Transport ] = AsyncHttpTransport
1028+ except RuntimeError :
1029+ # No event loop running, fall back to sync transport
1030+ logger .warning ("No event loop running, falling back to sync transport." )
1031+ transport_cls = Http2Transport if use_http2_transport else HttpTransport
10291032
10301033 if isinstance (ref_transport , Transport ):
10311034 return ref_transport
You can’t perform that action at this time.
0 commit comments