https://prefect.io logo
Title
t

Tony Popov

10/03/2022, 1:16 AM
A question on how to use async tasks: Context
class Result:
  pass

@task
async def my_task_1(arg: str) -> Result:
  ...

@task
async def my_task_2(arg: Result) -> None:
  ...
Question Doc says I can do
await my_task_1('arg')
in a flow, although mypy says
my_task_1('arg')
is not awaitable Is following a best practice?
task_result = await my_task.submit('arg')
result = await task_result.result()

await my_task_2.submit(result)
b

Bianca Hoch

10/03/2022, 10:27 PM
Hey Tony, assuming this is for 2.0, this article may help you out. Check out the very last post, it shows how to accomplish this in a cleaner syntax
t

Tony Popov

10/04/2022, 6:26 AM
@Bianca Hoch Thanks, mypy is certainly not accepting that approach though
b

Bianca Hoch

10/04/2022, 6:43 PM
Well that's unfortunate. Would you mind sharing the error message?