-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I use async/await with flask-restx? #600
Comments
The error you're encountering, "RuntimeWarning: coroutine 'AsyncResource.post' was never awaited," occurs because the async function somefunction() is not being awaited within the post method of the AsyncResource class. To address this issue, you should await the somefunction() call within the post method. Here's the modified code:
By incorporating the await keyword before somefunction(), you ensure that the asynchronous operation is properly awaited, resolving the runtime warning and allowing the code to function as expected. |
thanks for the response, but I did await, is it not showing in my example? the error that i am getting makes me think that whatever flask-restx is handling the call to AsyncResource.post() isn't using await |
this person at stackoverflow https://stackoverflow.com/questions/68115481/is-it-possible-to-use-flask-restx-wih-flasks-2-0-async-await also asked the same question with no realistic answer |
related to issue #366 |
Ask a question
I have a simple route like
when this route is called, i get an error saying that AsyncResource.post wasn't awaited
"RuntimeWarning: coroutine 'AsyncResource.post' was never awaited"
Additional context
the same function works when using normal flask[async]
The text was updated successfully, but these errors were encountered: