Skip to content

Commit 28315b7

Browse files
committed
Rearrange
1 parent 4bf62f7 commit 28315b7

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

tests/test_activity.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,54 +42,6 @@ async def blocking_increment(n: int) -> int:
4242
return n + 1
4343

4444

45-
async def _wait_for_notification_from_caller():
46-
"""
47-
Execute a workflow that waits for the caller to notify it.
48-
"""
49-
act = activity.info()
50-
await activity.client().execute_workflow(
51-
EventWorkflow.wait,
52-
id=f"to-activity-{act.activity_id}",
53-
task_queue=act.task_queue,
54-
)
55-
56-
57-
async def _wait_for_activity_to_start_executing(
58-
activity_handle: ActivityHandle, task_queue: str
59-
):
60-
"""
61-
Execute a workflow that waits for the activity to notify it.
62-
"""
63-
await activity_handle._client.execute_workflow(
64-
EventWorkflow.wait,
65-
id=f"from-activity-{activity_handle.activity_id}",
66-
task_queue=task_queue,
67-
)
68-
69-
70-
async def _notify_caller() -> None:
71-
"""
72-
Send a notification to the workflow that the caller is waiting on.
73-
"""
74-
await (
75-
activity.client()
76-
.get_workflow_handle_for(
77-
EventWorkflow.wait,
78-
workflow_id=f"from-activity-{activity.info().activity_id}",
79-
)
80-
.signal(EventWorkflow.set)
81-
)
82-
83-
84-
async def _notify_activity(activity_handle: ActivityHandle, task_queue: str) -> None:
85-
await _wait_for_activity_to_start_executing(activity_handle, task_queue)
86-
wf = activity_handle._client.get_workflow_handle_for(
87-
EventWorkflow.wait,
88-
workflow_id=f"to-activity-{activity_handle.activity_id}",
89-
)
90-
await wf.signal(EventWorkflow.set)
91-
92-
9345
# Activity classes for testing start_activity_class / execute_activity_class
9446
@activity.defn
9547
class IncrementClass:
@@ -1227,3 +1179,51 @@ async def wait(self) -> None:
12271179
@workflow.signal
12281180
def set(self) -> None:
12291181
self.signal_received.set()
1182+
1183+
1184+
async def _wait_for_notification_from_caller():
1185+
"""
1186+
Execute a workflow that waits for the caller to notify it.
1187+
"""
1188+
act = activity.info()
1189+
await activity.client().execute_workflow(
1190+
EventWorkflow.wait,
1191+
id=f"to-activity-{act.activity_id}",
1192+
task_queue=act.task_queue,
1193+
)
1194+
1195+
1196+
async def _wait_for_activity_to_start_executing(
1197+
activity_handle: ActivityHandle, task_queue: str
1198+
):
1199+
"""
1200+
Execute a workflow that waits for the activity to notify it.
1201+
"""
1202+
await activity_handle._client.execute_workflow(
1203+
EventWorkflow.wait,
1204+
id=f"from-activity-{activity_handle.activity_id}",
1205+
task_queue=task_queue,
1206+
)
1207+
1208+
1209+
async def _notify_caller() -> None:
1210+
"""
1211+
Send a notification to the workflow that the caller is waiting on.
1212+
"""
1213+
await (
1214+
activity.client()
1215+
.get_workflow_handle_for(
1216+
EventWorkflow.wait,
1217+
workflow_id=f"from-activity-{activity.info().activity_id}",
1218+
)
1219+
.signal(EventWorkflow.set)
1220+
)
1221+
1222+
1223+
async def _notify_activity(activity_handle: ActivityHandle, task_queue: str) -> None:
1224+
await _wait_for_activity_to_start_executing(activity_handle, task_queue)
1225+
wf = activity_handle._client.get_workflow_handle_for(
1226+
EventWorkflow.wait,
1227+
workflow_id=f"to-activity-{activity_handle.activity_id}",
1228+
)
1229+
await wf.signal(EventWorkflow.set)

0 commit comments

Comments
 (0)