Skip to content

Commit 3a8cb10

Browse files
committed
restoring get_event_loop for linux, but adding try/except block and creating a new loop with new_event_loop if needed
1 parent 696ed54 commit 3a8cb10

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pydra/engine/helpers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,16 @@ def get_open_loop():
649649
if os.name == "nt":
650650
loop = asyncio.ProactorEventLoop() # for subprocess' pipes on Windows
651651
else:
652-
loop = asyncio.SelectorEventLoop()
653-
asyncio.set_event_loop(loop)
652+
try:
653+
loop = asyncio.get_event_loop()
654+
# in case RuntimeError: There is no current event loop in thread 'MainThread'
655+
except RuntimeError:
656+
loop = asyncio.new_event_loop()
657+
asyncio.set_event_loop(loop)
658+
else:
659+
if loop.is_closed():
660+
loop = asyncio.new_event_loop()
661+
asyncio.set_event_loop(loop)
654662
return loop
655663

656664

0 commit comments

Comments
 (0)