Skip to content

Commit e75147e

Browse files
authored
implement is_running for asyncio loop (#1463)
1 parent 6948be1 commit e75147e

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

temporalio/worker/_workflow_instance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,6 +2882,9 @@ def call_exception_handler(self, context: _Context) -> None:
28822882
def get_debug(self) -> bool:
28832883
return False
28842884

2885+
def is_running(self) -> bool:
2886+
return True
2887+
28852888

28862889
class _WorkflowInboundImpl(WorkflowInboundInterceptor):
28872890
def __init__( # type: ignore

tests/worker/test_workflow.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7207,6 +7207,22 @@ async def test_in_workflow_util(client: Client):
72077207
)
72087208

72097209

7210+
@workflow.defn
7211+
class LoopIsRunningWorkflow:
7212+
@workflow.run
7213+
async def run(self) -> bool:
7214+
return asyncio.get_running_loop().is_running()
7215+
7216+
7217+
async def test_workflow_loop_is_running(client: Client):
7218+
async with new_worker(client, LoopIsRunningWorkflow) as worker:
7219+
assert await client.execute_workflow(
7220+
LoopIsRunningWorkflow.run,
7221+
id=f"workflow-{uuid.uuid4()}",
7222+
task_queue=worker.task_queue,
7223+
)
7224+
7225+
72107226
deadlock_interruptible_completed = 0
72117227

72127228

0 commit comments

Comments
 (0)