You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly to Flask, the framework should support async function for a view - see https://flask.palletsprojects.com/en/2.1.x/async-await/
Under the hood, Flask executes asyncio.run() and returns the resulting value to the client.
When trying to define the view function with async, one gets TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a coroutine.
Workaround is simply to create a "regular" sync function that executes (asyncio.run()) a separate async function but it could be simpler and match Flask functionality.
Our use case: use Google Cloud Functions from BigQuery Remote Function to call external APIs concurrently (using aiohttp).
The text was updated successfully, but these errors were encountered:
Is there any progress on this? I have a different use case (downloading and sending a file over the network, both function calls as coroutines), and a native support for async would be much appreciated compared to the asyncio.run() workaround.
I believe this is somewhat blocked by the threads worker of Gunicorn used under the hood. And Gunicorn itself has had issues with async workers for a long time, but the latest v21 release should unblock a lot of different things.
Similarly to Flask, the framework should support
async
function for a view - see https://flask.palletsprojects.com/en/2.1.x/async-await/Under the hood, Flask executes
asyncio.run()
and returns the resulting value to the client.When trying to define the view function with
async
, one getsTypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a coroutine.
Workaround is simply to create a "regular" sync function that executes (
asyncio.run()
) a separate async function but it could be simpler and match Flask functionality.Our use case: use Google Cloud Functions from BigQuery Remote Function to call external APIs concurrently (using
aiohttp
).The text was updated successfully, but these errors were encountered: