Berislav Lopac
03/28/2024, 6:01 PMRuntimeWarning: coroutine 'from_async.wait_for_call_in_loop_thread' was never awaited
Marvin
03/28/2024, 6:02 PMRuntimeWarning: coroutine 'from_async.wait_for_call_in_loop_thread' was never awaited
error typically occurs when an asynchronous coroutine is not being awaited, hence it's not executed as it should be, which can happen in async Python code.
The Prefect documentation and code examples I found didn't directly address this specific error message. However, the issue occurs in a generic context when you define a coroutine and do not use the await
keyword to ensure it gets executed within an async loop.
In Prefect, it's essential to use await
with asynchronous operations, particularly when interacting with flows or tasks that are defined as async functions. This ensures that the event loop waits for the coroutine's completion before proceeding. Failure to do this could result in this warning.
Make sure that in your Prefect code, whenever you have an async function, you await it properly. Here's an example of how to await an async function, lifted from the tested engine code in Prefect:
python
assert await state.result() == 1
Review your code to ensure that every coroutine has been awaited correctly. If the problem persists, it would be worth searching for similar issues on GitHub or consulting with the Prefect community.
Source references:
1. Prefect Troubleshooting Guide
2. Prefect Test Engine Code Example on GitHub