Skip to content

Commit d5107b0

Browse files
committed
add cancellation details arg to testing ActivityEnvironment cancel
1 parent 3ac224b commit d5107b0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

temporalio/testing/_activity.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@ def __init__(self) -> None:
7676
self._activities: Set[_Activity] = set()
7777
self.cancellation_details = None
7878

79-
def cancel(self) -> None:
79+
def cancel(self, cancellation_details: Optional[temporalio.activity.ActivityCancellationDetails] = None) -> None:
8080
"""Cancel the activity.
8181
82+
Args:
83+
cancellation_details: Optional details about the cancellation. When provided, these
84+
will be accessible through temporalio.activity.cancellation_details()
85+
in the activity after cancellation.
86+
8287
This only has an effect on the first call.
8388
"""
8489
if self._cancelled:
8590
return
8691
self._cancelled = True
92+
# Set cancellation details if provided
93+
if cancellation_details is not None:
94+
self.cancellation_details = cancellation_details
8795
for act in self._activities:
8896
act.cancel()
8997

0 commit comments

Comments
 (0)