Skip to content

Commit 633b90c

Browse files
authored
Making raise on cancellation the default (#935)
* Making raise on cancellation the default * Lint * Remove todo * Remove code from other feature
1 parent a98d6fd commit 633b90c

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

temporalio/worker/_workflow_instance.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,16 +1620,14 @@ async def run_activity() -> Any:
16201620
# If an activity future completes at the same time as a cancellation is being processed, the cancellation would be swallowed
16211621
# _WorkflowLogicFlag.RAISE_ON_CANCELLING_COMPLETED_ACTIVITY will correctly reraise the exception
16221622
if handle._result_fut.done():
1623-
# TODO in next release, check sdk flag when not replaying instead of global override, remove the override, and set flag use
16241623
if (
1625-
(
1626-
not self._is_replaying
1627-
and _raise_on_cancelling_completed_activity_override
1628-
)
1624+
not self._is_replaying
16291625
or _WorkflowLogicFlag.RAISE_ON_CANCELLING_COMPLETED_ACTIVITY
16301626
in self._current_internal_flags
16311627
):
1632-
# self._current_completion.successful.used_internal_flags.append(WorkflowLogicFlag.RAISE_ON_CANCELLING_COMPLETED_ACTIVITY)
1628+
self._current_completion.successful.used_internal_flags.append(
1629+
_WorkflowLogicFlag.RAISE_ON_CANCELLING_COMPLETED_ACTIVITY
1630+
)
16331631
raise
16341632
# Send a cancel request to the activity
16351633
handle._apply_cancel_command(self._add_command())
@@ -3138,7 +3136,3 @@ class _WorkflowLogicFlag(IntEnum):
31383136
"""Flags that may be set on task/activation completion to differentiate new from old workflow behavior."""
31393137

31403138
RAISE_ON_CANCELLING_COMPLETED_ACTIVITY = 1
3141-
3142-
3143-
# Used by tests to validate behavior prior to SDK flag becoming default
3144-
_raise_on_cancelling_completed_activity_override = False

tests/worker/test_workflow.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8005,8 +8005,6 @@ async def test_quick_activity_swallows_cancellation(client: Client):
80058005
activities=[short_activity_async],
80068006
activity_executor=concurrent.futures.ThreadPoolExecutor(max_workers=1),
80078007
) as worker:
8008-
temporalio.worker._workflow_instance._raise_on_cancelling_completed_activity_override = True
8009-
80108008
for i in range(10):
80118009
wf_duration = random.uniform(5.0, 15.0)
80128010
wf_handle = await client.start_workflow(
@@ -8028,8 +8026,6 @@ async def test_quick_activity_swallows_cancellation(client: Client):
80288026
assert isinstance(cause, CancelledError)
80298027
assert cause.message == "Workflow cancelled"
80308028

8031-
temporalio.worker._workflow_instance._raise_on_cancelling_completed_activity_override = False
8032-
80338029

80348030
async def test_workflow_logging_trace_identifier(client: Client):
80358031
with LogCapturer().logs_captured(

0 commit comments

Comments
 (0)