PrefectHQ
prefect
BlogDocsChangelog

fix async task transaction rollback from sync task

#19097Merged
Comparing
fix/async-task-transaction-rollback
(
5d6c5aa
) with
main
(
c842e8a
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
458.9 µs459.5 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.3 s1.4 s

Ignored

bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
2.6 ms2.6 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+26%
4.8 ms3.8 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+21%
5.2 ms4.3 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+1%
169.5 ms167.9 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
105.8 ms106.1 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-1%
164.7 ms167 ms

Commits

Click on a commit to change the comparison range
Base
main
c842e8a
-0.16%
fix async task transaction rollback from sync task this PR fixes a bug where submitting an async task from within a sync task would fail with "object bool can't be used in 'await' expression" when the async task raised an exception. <details> <summary>details</summary> the issue occurred in `AsyncTransaction.reset()` when rolling back a failed transaction. when an async task is submitted from within a sync task, the parent transaction is a sync `Transaction` (not an `AsyncTransaction`). the code tried to `await parent.rollback()`, but since the parent is sync, its `rollback()` method returns a `bool`, which can't be awaited. the fix checks if the parent is an `AsyncTransaction` before awaiting, following the same pattern used in `AsyncTransaction.rollback()` when handling children transactions. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5d6c5aa
6 days ago
by zzstoatzz
© 2025 CodSpeed Technology
Home Terms Privacy Docs