Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion temporalio/client/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,9 @@ async def terminate_activity(self, input: TerminateActivityInput) -> None:
namespace=self._client.namespace,
activity_id=input.activity_id,
run_id=input.activity_run_id or "",
reason=input.reason or "",
identity=self._client.identity,
request_id=str(uuid.uuid4()),
reason=input.reason or "",
),
retry=True,
metadata=input.rpc_metadata,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_activity_operator_commands_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import uuid
from datetime import timedelta
from typing import Any
from unittest.mock import AsyncMock, Mock
Expand All @@ -27,6 +28,10 @@ def __init__(self) -> None:
"unpause",
temporalio.api.workflowservice.v1.UnpauseActivityExecutionResponse(),
)
self.terminate_activity_execution = self._recorder(
"terminate",
temporalio.api.workflowservice.v1.TerminateActivityExecutionResponse(),
)
self.update_activity_execution_options = self._recorder(
"update",
temporalio.api.workflowservice.v1.UpdateActivityExecutionOptionsResponse(
Expand Down Expand Up @@ -201,3 +206,18 @@ async def test_update_options_masks_only_changed_options(
assert update.activity_options.start_to_close_timeout.ToTimedelta() == timedelta(
seconds=90
)


async def test_terminate_activity_sends_request_id_and_reason(
client: Client, captured: _CapturedService
):
handle = client.get_activity_handle("act-1")
await handle.terminate(reason="term-reason")

req = captured.requests["terminate"]
assert req.activity_id == "act-1"
assert req.reason == "term-reason"
assert req.identity == "test-identity"
assert req.namespace == "test-namespace"
assert req.request_id
assert uuid.UUID(req.request_id)
Loading