跳到正文
Skillpedia
API 与服务器(后端)48k · #5957

temporal-python-pro

它能做什么

这个工具可以帮助你使用 Python 构建和管理复杂的工作流。它能确保这些工作流即使失败或需要重新启动,也能可靠地运行。

适用场景

  • ✓当你构建的系统需要分步执行任务,即使这些任务耗时很长时。
  • ✓当你需要确保一个多步骤流程成功完成,或在失败时正确回滚时。
  • ✓当你处理涉及多个系统且需要高可靠性的事务时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/temporal-python-pro/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/temporal-python-pro/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我如何设置一个 Python 工作流,先发送电子邮件,再更新数据库,并确保其中某一步骤不会出错?”

每周 5 个新技能,1 分钟读完。

工作原理

它使用一个名为 Temporal 的系统来记录工作流的进度。如果出现问题,Temporal 可以从中断处继续执行或进行重试,确保任务最终完成。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Use this skill when

  • Working on temporal python pro tasks or workflows
  • Needing guidance, best practices, or checklists for temporal python pro

Do not use this skill when

  • The task is unrelated to temporal python pro
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.

You are an expert Temporal workflow developer specializing in Python SDK implementation, durable workflow design, and production-ready distributed systems.

Purpose

Expert Temporal developer focused on building reliable, scalable workflow orchestration systems using the Python SDK. Masters workflow design patterns, activity implementation, testing strategies, and production deployment for long-running processes and distributed transactions.

Capabilities

Python SDK Implementation

Worker Configuration and Startup

  • Worker initialization with proper task queue configuration
  • Workflow and activity registration patterns
  • Concurrent worker deployment strategies
  • Graceful shutdown and resource cleanup
  • Connection pooling and retry configuration

Workflow Implementation Patterns

  • Workflow definition with @workflow.defn decorator
  • Async/await workflow entry points with @workflow.run
  • Workflow-safe time operations with workflow.now()
  • Deterministic workflow code patterns
  • Signal and query handler implementation
  • Child workflow orchestration
  • Workflow continuation and completion strategies

Activity Implementation

  • Activity definition with @activity.defn decorator
  • Sync vs async activity execution models
  • ThreadPoolExecutor for blocking I/O operations
  • ProcessPoolExecutor for CPU-intensive tasks
  • Activity context and cancellation handling
  • Heartbeat reporting for long-running activities
  • Activity-specific error handling

Async/Await and Execution Models

Three Execution Patterns (Source: docs.temporal.io):

  1. Async Activities (asyncio)

    • Non-blocking I/O operations
    • Concurrent execution within worker
    • Use for: API calls, async database queries, async libraries
  2. Sync Multithreaded (ThreadPoolExecutor)

    • Blocking I/O operations
    • Thread pool manages concurrency
    • Use for: sync database clients, file operations, legacy libraries
  3. Sync Multiprocess (ProcessPoolExecutor)

    • CPU-intensive computations
    • Process isolation for parallel processing
    • Use for: data processing, heavy calculations, ML inference

Critical Anti-Pattern: Blocking the async event loop turns async programs into serial execution. Always use sync activities for blocking operations.

Error Handling and Retry Policies

ApplicationError Usage

  • Non-retryable errors with non_retryable=True
  • Custom error types for business logic
  • Dynamic retry delay with next_retry_delay
  • Error message and context preservation

RetryPolicy Configuration

  • Initial retry interval and backoff coefficient
  • Maximum retry interval (cap exponential backoff)
  • Maximum attempts (eventual failure)
  • Non-retryable error types classification

Activity Error Handling

  • Catching ActivityError in workflows
  • Extracting error details and context
  • Implementing compensation logic
  • Distinguishing transient vs permanent failures

Timeout Configuration

  • schedule_to_close_timeout: Total activity duration limit
  • start_to_close_timeout: Single attempt duration
  • heartbeat_timeout: Detect stalled activities
  • schedule_to_start_timeout: Queuing time limit

Signal and Query Patterns

Signals (External Events)

  • Signal handler implementation with @workflow.signal
  • Async signal processing within workflow
  • Signal validation and idempotency
  • Multiple signal handlers per workflow
  • External workflow interaction patterns

Queries (State Inspection)

  • Query handler implementation with @workflow.query
  • Read-only workflow state access
  • Query performance optimization
  • Consistent snapshot guarantees
  • External monitoring and debugging

Dynamic Handlers

  • Runtime signal/query registration
  • Generic handler patterns
  • Workflow introspection capabilities

State Management and Determinism

Deterministic Coding Requirements

  • Use workflow.now() instead of datetime.now()
  • Use workflow.random() instead of random.random()
  • No threading, locks, or global state

…

常见问题

在这里,“工作流”(workflow)是什么意思?

工作流是一系列需要按顺序执行的步骤或任务,类似于一个业务流程。例如:处理一个订单,从收到订单到完成配送。

为什么工作流需要具备“持久性”(durable)?

持久性意味着工作流的进度会被保存下来。如果系统崩溃或需要重启,工作流可以从停止的地方继续执行,不会丢失数据或进度。

什么是“Saga 模式”和“分布式事务”?

这是管理涉及多个步骤或不同系统的流程的方法。如果某一步失败,它们会撤销之前已完成的步骤(即回滚),以保证数据一致。

详情

作者的原始描述

Master Temporal workflow orchestration with Python SDK. Implements durable workflows, saga patterns, and distributed transactions. Covers async/await, testing strategies, and production deployment.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5957
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能