Avatar for the PrefectHQ user
PrefectHQ
prefect
BlogDocsChangelog

Migrate states functions from sync_compatible to async_dispatch

#18417
Comparing
migrate-states-async-dispatch
(
d8708f4
) with
main
(
0efc8d5
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
2
New
0
Dropped
0
Ignored
6

Benchmarks

Passed

bench_import_prefect_flow
benches/bench_import.py::bench_import_prefect_flow
CodSpeed Performance Gauge
0%
1.3 s
1.3 s
bench_task_decorator
benches/bench_tasks.py::bench_task_decorator
CodSpeed Performance Gauge
-1%
456.9 µs
460.6 µs

Ignored

bench_flow_call[options0]Ignored
benches/bench_flows.py::bench_flow_call[options0]
CodSpeed Performance Gauge
-1%
165 ms
166.9 ms
bench_flow_call[options1]Ignored
benches/bench_flows.py::bench_flow_call[options1]
CodSpeed Performance Gauge
0%
105.9 ms
105.7 ms
bench_flow_decoratorIgnored
benches/bench_flows.py::bench_flow_decorator
CodSpeed Performance Gauge
+26%
4.8 ms
3.8 ms
bench_import_prefectIgnored
benches/bench_import.py::bench_import_prefect
CodSpeed Performance Gauge
0%
2.7 ms
2.7 ms
bench_task_callIgnored
benches/bench_tasks.py::bench_task_call
CodSpeed Performance Gauge
+3%
167 ms
162.8 ms
bench_task_submitIgnored
benches/bench_tasks.py::bench_task_submit
CodSpeed Performance Gauge
+65%
4.4 ms
2.7 ms

Commits

Click on a commit to change the comparison range
Base
main
0efc8d5
0%
Migrate states functions from sync_compatible to async_dispatch This PR migrates get_state_exception and raise_state_exception from the sync_compatible decorator to the async_dispatch pattern. Since these functions involve async operations (ResultStore operations and recursive calls), the sync versions are implemented as thin wrappers using run_coro_as_sync. Changes: - Renamed async functions with 'a' prefix (aget_state_exception, araise_state_exception) - Created sync versions that use run_coro_as_sync to call async versions - Added async_dispatch decorator to connect sync/async implementations - Updated recursive calls within the functions to use the async versions - Added tests to verify correct dispatch behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3ac93f0
2 days ago
by zzstoatzz
0%
Fix async state exception calls in _get_state_result When using async_dispatch pattern, async code should call the explicit async version (aget_state_exception) rather than the dispatching function (get_state_exception) to avoid type errors. This fixes failing test: test_task_passes_failed_state_to_retry_fn_sync 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
d8708f4
2 days ago
by zzstoatzz
© 2025 CodSpeed Technology
Home Terms Privacy Docs