Async Python Is Secretly Deterministic
3 hours ago
- #async programming
- #determinism
- #workflow orchestration
- Adding async support to Python durable execution libraries requires deterministic workflow execution for replay-based recovery.
- Concurrent async steps, such as those using asyncio.gather, introduce non-deterministic execution order due to overlapping task execution.
- The async Python event loop schedules tasks in a FIFO order, allowing deterministic step ID assignment before the first await in each task.
- By assigning step IDs deterministically in the order tasks are passed to asyncio.gather, workflows can achieve both concurrency and deterministic replay.