File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
osrf_pycommon/process_utils Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,19 @@ def get_loop_impl(asyncio):
2424 return asyncio .get_event_loop ()
2525 # Setup this thread's loop and return it
2626 if os .name == 'nt' :
27- loop = asyncio .ProactorEventLoop ()
28- asyncio .set_event_loop (loop )
27+ try :
28+ loop = asyncio .get_event_loop ()
29+ if not isinstance (loop , asyncio .ProactorEventLoop ):
30+ # Before replacing the existing loop, explicitly
31+ # close it to prevent an implicit close during
32+ # garbage collection, which may or may not be a
33+ # problem depending on the loop implementation.
34+ loop .close ()
35+ loop = asyncio .ProactorEventLoop ()
36+ asyncio .set_event_loop (loop )
37+ except (RuntimeError , AssertionError ):
38+ loop = asyncio .ProactorEventLoop ()
39+ asyncio .set_event_loop (loop )
2940 else :
3041 try :
3142 loop = asyncio .get_event_loop ()
You can’t perform that action at this time.
0 commit comments