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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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.defndecorator - 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.defndecorator - 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):
Async Activities (asyncio)
- Non-blocking I/O operations
- Concurrent execution within worker
- Use for: API calls, async database queries, async libraries
Sync Multithreaded (ThreadPoolExecutor)
- Blocking I/O operations
- Thread pool manages concurrency
- Use for: sync database clients, file operations, legacy libraries
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
ActivityErrorin workflows - Extracting error details and context
- Implementing compensation logic
- Distinguishing transient vs permanent failures
Timeout Configuration
schedule_to_close_timeout: Total activity duration limitstart_to_close_timeout: Single attempt durationheartbeat_timeout: Detect stalled activitiesschedule_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 ofdatetime.now() - Use
workflow.random()instead ofrandom.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.
热度
- GitHub 星标
- 48k
- 排名
- #5957
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。