Skip to content

Commit bca3fa9

Browse files
committed
fix(worker): event loop should run until yield
Signed-off-by: Shijie Sheng <[email protected]>
1 parent 273f7d0 commit bca3fa9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

cadence/_internal/workflow/deterministic_event_loop.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ def __init__(self):
2727
self._stopping = False
2828
self._closed = False
2929

30+
def run_until_yield(self):
31+
"""Run until stop() is called."""
32+
self._run_forever_setup()
33+
try:
34+
while self._ready:
35+
self._run_once()
36+
finally:
37+
self._run_forever_cleanup()
38+
39+
# Event Loop APIs
3040
def call_soon(
3141
self,
3242
callback: Callable[[Unpack[_Ts]], object],

cadence/_internal/workflow/workflow_engine.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,7 @@ def _execute_workflow_once(
225225
self._workflow_instance.run(workflow_input)
226226
)
227227

228-
# signal the loop to stop after the first run
229-
self._loop.stop()
230-
# this starts the loop and runs once then stops with cleanup
231-
self._loop.run_forever()
228+
self._loop.run_until_yield()
232229

233230
except Exception as e:
234231
logger.error(

0 commit comments

Comments
 (0)