@@ -26,7 +26,7 @@ async def via_create_task():
26
26
await asyncio .Future ()
27
27
raise RuntimeError ("Unreachable" )
28
28
except asyncio .CancelledError :
29
- activity .heartbeat ("cancelled" )
29
+ activity .heartbeat (f "cancelled= { activity . cancellation_details (). cancel_requested } " , )
30
30
return "done"
31
31
32
32
env = ActivityEnvironment ()
@@ -37,9 +37,9 @@ async def via_create_task():
37
37
task = asyncio .create_task (env .run (do_stuff , "param1" ))
38
38
await waiting .wait ()
39
39
# Cancel and confirm done
40
- env .cancel ()
40
+ env .cancel (cancellation_details = activity . ActivityCancellationDetails ( cancel_requested = True ) )
41
41
assert "done" == await task
42
- assert heartbeats == ["param: param1" , "task, type: unknown" , "cancelled" ]
42
+ assert heartbeats == ["param: param1" , "task, type: unknown" , "cancelled=True " ]
43
43
44
44
45
45
def test_activity_env_sync ():
@@ -72,7 +72,7 @@ def via_thread():
72
72
raise RuntimeError ("Unexpected" )
73
73
except CancelledError :
74
74
nonlocal properly_cancelled
75
- properly_cancelled = True
75
+ properly_cancelled = activity . cancellation_details (). cancel_requested
76
76
77
77
env = ActivityEnvironment ()
78
78
# Set heartbeat handler to add to list
@@ -84,7 +84,7 @@ def via_thread():
84
84
waiting .wait ()
85
85
# Cancel and confirm done
86
86
time .sleep (1 )
87
- env .cancel ()
87
+ env .cancel (cancellation_details = activity . ActivityCancellationDetails ( cancel_requested = True ) )
88
88
thread .join ()
89
89
assert heartbeats == ["param: param1" , "task, type: unknown" ]
90
90
assert properly_cancelled
0 commit comments