Skip to content

Commit

Permalink
Some notes for future reference
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Feb 5, 2025
1 parent 45b7423 commit 1a10c5f
Show file tree
Hide file tree
Showing 2 changed files with 1,053 additions and 1,034 deletions.
11 changes: 9 additions & 2 deletions src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ def __init__(
# Don't allow the spec to be changed anymore
self.spec().seal()

self._loop = loop if loop is not None else asyncio.get_event_loop()
# self._loop = loop or asyncio.get_running_loop()
self._loop = None

self._setup_event_hooks()

Expand Down Expand Up @@ -1311,7 +1312,13 @@ def execute(self) -> Optional[Dict[str, Any]]:

if not self.has_terminated():
coro = self.step_until_terminated()
with get_runner(loop=self.loop) as runner:
# FIXME: define loop in process init is problematic, since it may get the main thread
# event loop and close it unexpectly. I think should be only two type of entries where
# the event loop definition is clear.
# A. if there already a running loop, create a thread with event loop to offload run, and support nested
# B. if there is no loop, create its own that can nested using greenlet
loop = self.loop or asyncio.get_running_loop()
with get_runner(loop=loop) as runner:
print('I got runner: ', runner)
result = runner.run(coro)

Expand Down
Loading

0 comments on commit 1a10c5f

Please sign in to comment.