Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cadence/_internal/workflow/deterministic_event_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ def __init__(self):
self._stopping = False
self._closed = False

def run_until_yield(self):
"""Run until stop() is called."""
self._run_forever_setup()
try:
while self._ready:
self._run_once()
finally:
self._run_forever_cleanup()

# Event Loop APIs
def call_soon(
self,
callback: Callable[[Unpack[_Ts]], object],
Expand Down
5 changes: 1 addition & 4 deletions cadence/_internal/workflow/workflow_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,7 @@ def _execute_workflow_once(
self._workflow_instance.run(workflow_input)
)

# signal the loop to stop after the first run
self._loop.stop()
# this starts the loop and runs once then stops with cleanup
self._loop.run_forever()
self._loop.run_until_yield()

except Exception as e:
logger.error(
Expand Down