Installation
Install PyWorkflow using pip:Prerequisites
PyWorkflow requires Redis and Celery workers for distributed execution.- Docker Compose (Recommended)
- Manual Setup
The easiest way to get started is with Docker Compose:This starts Redis, Celery workers, and Celery Beat automatically.
Your First Workflow
Create a simple onboarding workflow that sends emails with delays:What Happens Under the Hood
1
Workflow Starts
Your workflow is dispatched to an available Celery worker.
2
Welcome Email Sent
The
send_welcome_email step executes and the result is recorded.3
Workflow Suspends
When
sleep("1d") is called, the workflow suspends and the worker is freed.
Zero resources are consumed during the sleep period.4
Automatic Resumption
After 1 day, Celery Beat automatically schedules the workflow to resume.
5
Tips Email Sent
The workflow picks up where it left off, sending the tips email.
6
Workflow Completes
The final result is recorded and the workflow is marked as complete.
Key Concepts
Workflows
Top-level orchestration functions that coordinate steps and handle business logic.
Steps
Isolated, retryable units of work that run on Celery workers.
Sleep
Pause workflows for any duration without consuming resources.
Events
Event sourcing provides durability and deterministic replay.
Adding Error Handling
Make your workflows fault-tolerant with automatic retries:Running in Parallel
Execute multiple steps concurrently usingasyncio.gather():