cnsmyth
09/19/2024, 7:39 PMRuntimeWarning: coroutine 'run_task_async' was never awaited
return fn(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Probably related?Nate
09/19/2024, 9:37 PMawait
your run_task_async
or add _sync=True
Nate
09/19/2024, 9:38 PMNate
09/19/2024, 9:45 PMcnsmyth
09/19/2024, 10:46 PMawait
the function that calls email_send_message
... but maybe I did that wrong. Do you have additional documentation I can read on await to ensure I implement that correctly?Nate
09/19/2024, 10:51 PMasync def some_async_fn
) then you must use them like async functions (prefect 2 magically did this for you, which caused other problems, so that's why you're seeing this now)
• if you use block methods in a sync context, you don't need to await them, you can treat them like normal sync functionsDave D
10/07/2024, 9:01 PMNate
10/07/2024, 9:02 PMshell_run_command
is just an async task, so it won't accept _sync=True
like things that are decorated with sync_compatible
(all of this sync / async stuff is a bit confusing, and we're working on clearing that up soon)
> await doesnt seem to work
can you explain?Dave D
10/07/2024, 9:04 PMThe output of shell_run_command: <coroutine object run_task_async at 0x7ffffb6da5c0>
/usr/local/lib/python3.12/json/decoder.py:353: RuntimeWarning: coroutine 'run_task_async' was never awaited
Dave D
10/07/2024, 9:05 PMDave D
10/07/2024, 9:07 PMNate
10/07/2024, 9:08 PMok apparently prefect_shell was moved into prefect coreand yep
The output of shell_run_command: <coroutine object run_task_async at 0x7ffffb6da5c0>
/usr/local/lib/python3.12/json/decoder.py353 RuntimeWarning: coroutine 'run_task_async' was never awaitedim guessing you're calling
shell_run_command
from within a sync function?
like def some_func()
Dave D
10/07/2024, 9:08 PMDave D
10/07/2024, 9:09 PMoutput = shell_run_command.with_options(
name=f"shell_run_command-{name}"
)(
command=SHELL_SCRIPT,
return_all=True,
stream_level=logging.DEBUG
)
<http://logger.info|logger.info>(f"The output of shell_run_command: {output}")
Nate
10/07/2024, 9:10 PMshell_run_command
function is async, you need to await
it
if you're in a sync context, use
named_task = shell_run_command.with_options(
name=f"shell_run_command-{name}"
)
output = asyncio.run(
named_task(
command=SHELL_SCRIPT,
return_all=True,
stream_level=logging.DEBUG
)
)
logger.info(f"The output of shell_run_command: {output}")
if you're in an async context await the function
output = await shell_run_command.with_options( # added await here
name=f"shell_run_command-{name}"
)(
command=SHELL_SCRIPT,
return_all=True,
stream_level=logging.DEBUG
)
logger.info(f"The output of shell_run_command: {output}")
Dave D
10/07/2024, 9:13 PMDave D
10/07/2024, 9:14 PM