和顺 / 衡律 返回所属 Agent
21.7

调用限制与故障恢复

原能力

实施限流、并发、预算、熔断和恢复,不以自动重试重复产生外部效果。(合同附件 R7 21.7)

首选项目

Temporal Python SDK(MIT,限 SDK)。 Temporal Python SDK

匹配范围

RetryPolicy、超时与工作流历史能恢复已知阶段。

源码

Temporal Python SDK · class RetryPolicy

temporalio/common.py · 37–50 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
class RetryPolicy:
    """Options for retrying workflows and activities."""

    initial_interval: timedelta = timedelta(seconds=1)
    """Backoff interval for the first retry. Default 1s."""

    backoff_coefficient: float = 2.0
    """Coefficient to multiply previous backoff interval by to get new
    interval. Default 2.0.
    """

    maximum_interval: timedelta | None = None
    """Maximum backoff interval between retries. Default 100x
    :py:attr:`initial_interval`.

Temporal Python SDK · async def execute_activity(

temporalio/workflow/_activities.py · 337–350 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
async def execute_activity(
    activity: CallableAsyncNoParam[ReturnType],
    *,
    task_queue: str | None = None,
    schedule_to_close_timeout: timedelta | None = None,
    schedule_to_start_timeout: timedelta | None = None,
    start_to_close_timeout: timedelta | None = None,
    heartbeat_timeout: timedelta | None = None,
    retry_policy: temporalio.common.RetryPolicy | None = None,
    cancellation_type: ActivityCancellationType = ActivityCancellationType.TRY_CANCEL,
    activity_id: str | None = None,
    versioning_intent: VersioningIntent | None = None,
    summary: str | None = None,
    event_groups: Sequence[EventGroup] | None = None,

实现与验收要点

服务限额、何时能重发、原请求查证和权限。