Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Retried `ActivityHandle.terminate()` can fail after the activity is already terminated

未关闭
#2,008 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@maciejdudko 已经在做这个了。

开始于 2026年10月22日。

  • #2009 来自 @RaphaelFakhri —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

What are you really trying to do?

Terminate a standalone activity with ActivityHandle.terminate() and rely on the client's built-in RPC retries.

Describe the bug

_ClientImpl.terminate_activity in temporalio/client/_impl.py builds TerminateActivityExecutionRequest without request_id and sends it with retry=True. The sibling calls (cancel_activity, pause_activity, unpause_activity, start_activity) all set request_id=str(uuid.uuid4()), and the Go SDK sets RequestId on this request too.

On the server, an empty request ID is replaced with a new random one for each attempt (validateAndNormalizeRequestID in chasm/lib/activity/validator.go). Activity.Terminate returns success for a repeat only when the request ID matches the stored one, and otherwise returns NotFound: no running activity execution: it closed with status TERMINATED. So if the first attempt terminates the activity but the response is lost (for example a transient UNAVAILABLE), the automatic retry fails and terminate() raises although the activity was terminated.

Minimal Reproduction
from unittest import mock

import temporalio.api.workflowservice.v1
from temporalio.client import Client


async def main() -> None:
    rpc = mock.AsyncMock(
        return_value=temporalio.api.workflowservice.v1.TerminateActivityExecutionResponse()
    )
    service_client = mock.MagicMock()
    service_client.config.identity = "test-identity"
    service_client.workflow_service.terminate_activity_execution = rpc
    client = Client(service_client)
    await client.get_activity_handle("my-activity").terminate(reason="done")
    print(repr(rpc.call_args.args[0].request_id))  # prints '' on main
Environment/Versions
  • SDK: main at 600cbec
  • Python 3.13, Linux x86_64
Additional context

Adding request_id=str(uuid.uuid4()) to the request makes retries of the same call idempotent, matching the other activity operator calls.

主要语言
Python
星标
1.2k
派生
269
平均合并
1 天 11 小时
30 天内合并 PR
68

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

temporalio/sdk-python 的其他 Issue

查看 temporalio/sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。