flask-restx
flask-restx copied to clipboard
Make api.route() work with Flask 2.x async endpoints
If you add a resource to your API with the decorator your actual functions get wrapped in the output
function. before being added as an url_rule. (right about here: https://github.com/python-restx/flask-restx/blob/master/flask_restx/api.py#L359)
Since the output function is synchronous Flask 2.x won't detect the actual endpoint function is a coroutine.
So that function will never be awaited and as a consequence not work.
Describe the solution you'd like It would be great if Flask Restx would integrate seamlessly with Flask 2.x. I suppose you can either make the output function async and this will probably just work under Flask 2.x but break under earlier versions or detect if your endpoint is a coroutine and add the correct output wrapper depending on that
Describe alternatives you've considered Currently I'm using the https://github.com/alex-sherman/unsync library as a workaround so I can keep my underlying async functions and use Flask Restx
thanks for opening this request! This indeed would be a great addition bring restx up to parity with flask.
Any updates here?
flask 2.0 async compatibility would be a great enhancement.
Could really use this!
Would love this as well. Anyone figure out how unsync can get around this?
👍 flask-restx is a great lib, async capabilities are the only thing missing in this
even with flask > 3.0 and flask-restx 1.3 it still not working