Open airedwin opened 7 months ago
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: @ns_async.route('/async') class AsyncResource(Resource): async def post(self,):
await somefunction()
return jsonify({
'status': 'success'
}), 200
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.
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: @ns_async.route('/async') class AsyncResource(Resource): async def post(self,): # Await the somefunction() call await somefunction()
return jsonify({ 'status': 'success' }), 200
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]