Tasks¶
A task is a Python callable decorated with @task from prefect_compat. Each scheduled execution becomes a task run with its own state machine in the Rust engine, tied to the parent flow run.
Basics¶
task.submit(*args, wait_for=...)— schedule work and get a future; usefuture.result()orwait([...])to block inside the flow function.task.map(values, wait_for=...)— fan out over inputs; returns a list of futures. Combine withwait(mapped)before downstreamsubmitcalls.- Imports and patterns match the subset described in Compatibility matrix and the Quick start (demo flow) example.
Transition hooks¶
Tasks accept the same transition_hooks mechanism as flows: TransitionHookSpec + on_transition, with optional from_state / to_state filters. See Flows and the compatibility matrix for behavior and differences from Prefect’s hook names.