Hey, folks! When I run this code: ```from prefect ...
# ask-community
n
Hey, folks! When I run this code:
Copy code
from 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:
Copy code
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 🧵
I'm on Prefect 3.4.21 but have seen this error in Prefect 3.3 as well. Interestingly, I don't get the "object bool can't be used in 'await' expression" error when I run this. So something seems different about using the task future in a flow versus in a task.
Copy code
from prefect import flow, task

@task
async def async_task():
    raise ValueError("aah!")

@flow
def my_flow():
    async_task.submit().result()

my_flow()
n
hmm this looks like a bug related to nested task transactions
🙏 1
taking a look
thanks for raising @Nick Ackerman -
prefect==3.4.22
is out now with the fix, running your example now raises the
ValueError
as you probably expected copying your original snippet:
Copy code
pbpaste | uv run --with prefect==3.4.22 -
...
Copy code
File "<string>", line 5, in async_task
ValueError: aah!
❤️ 1
n
This is amazing - thank you so much, Nate!
n
catjam