Skip to content

Commit 5f65535

Browse files
committed
poe lint
1 parent e6772d4 commit 5f65535

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

resource_locking/lock_manager_workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from dataclasses import dataclass
22
from datetime import timedelta
3+
from typing import Optional
34

45
from temporalio import workflow
56

@@ -163,7 +164,7 @@ async def handoff_resource(self, request: HandoffRequest):
163164
await requester.signal("assign_resource", AssignedResource(request.resource))
164165

165166
@workflow.query
166-
def get_current_holders(self) -> dict[str, AcquireRequest]:
167+
def get_current_holders(self) -> dict[str, Optional[AcquireRequest]]:
167168
return {k: v[0] if v else None for k, v in self.resource_queues.items()}
168169

169170
@workflow.run

resource_locking/resource_locking_workflow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def run(self, input: ResourceLockingWorkflowInput):
8282
await sem_handle.signal(
8383
"acquire_resource", AcquireRequest(info.workflow_id, info.run_id)
8484
)
85-
else:
85+
elif info.continued_run_id:
8686
# If we continued as new, we already have a resource. We need to transfer ownership from our predecessor to
8787
# ourselves.
8888
await sem_handle.signal(
@@ -94,6 +94,10 @@ async def run(self, input: ResourceLockingWorkflowInput):
9494
info.run_id,
9595
),
9696
)
97+
else:
98+
raise FailWorkflowException(
99+
f"Only set 'already_owned_resource' when using continue_as_new"
100+
)
97101

98102
# Both branches above should cause us to receive an "assign_resource" signal.
99103
await workflow.wait_condition(

0 commit comments

Comments
 (0)