Nick Ackerman
10/03/2025, 5:17 PMfrom prefect import flow, task
@task
async def async_task():
raise ValueError("aah!")
@task
def not_async_task():
async_task.submit().result()
@flow
def my_flow():
not_async_task()
my_flow()
I get the following error:
File "/Users/nickackerman/code/python/practice/.venv/lib/python3.10/site-packages/prefect/transactions.py", line 624, in __aexit__
await self.reset()
File "/Users/nickackerman/code/python/practice/.venv/lib/python3.10/site-packages/prefect/transactions.py", line 492, in reset
await parent.rollback()
TypeError: object bool can't be used in 'await' expression
Is this way of using Prefect futures together with async tasks not allowed for some reason? More details in 🧵Nick Ackerman
10/03/2025, 5:19 PMfrom prefect import flow, task
@task
async def async_task():
raise ValueError("aah!")
@flow
def my_flow():
async_task.submit().result()
my_flow()
Nate
10/03/2025, 5:28 PMNate
10/03/2025, 5:28 PMNate
10/03/2025, 5:45 PMNate
10/03/2025, 6:43 PMprefect==3.4.22
is out now with the fix, running your example now raises the ValueError
as you probably expected
copying your original snippet:
pbpaste | uv run --with prefect==3.4.22 -
...
File "<string>", line 5, in async_task
ValueError: aah!
Nick Ackerman
10/03/2025, 8:37 PMNate
10/03/2025, 8:38 PM