@login_required with Flask 2.0 Async Routes, does not return a valid response
See original GitHub issueDescribe the bug When using @login_required with Flask 2.0 Async Routes I get an error.
To Reproduce Steps to reproduce the behavior: Flask 2.0.1 Werkzeug 2.0.1 Flask-Login 0.5.0
@api.route('/v1.0/check_async2')
async def check_async2():
await asyncio.sleep(1)
return "Hello"
@api.route('/v1.0/check_async3')
@login_required
async def check_async3():
await asyncio.sleep(1)
return "Hello"
Expected behavior Both should return “Hello”. However the second (check_async3) returns the following error:
"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."
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Using async and await — Flask Documentation (2.2.x)
When a request comes in to an async view, Flask will start an event loop in a thread, run the view function there,...
Read more >Async in Flask 2.0 - TestDriven.io
Starting with Flask 2.0, you can create asynchronous route handlers ... async def async_get_data(): await asyncio.sleep(1) return 'Done!
Read more >Flask login @login_required not working - Stack Overflow
My problem was that the @flask_login.login_required decorator was above the @app.route('<path>') decorator, so I just replaced them and it ...
Read more >The Art of Routing in Flask - Hackers and Slackers
Providing a list of accepted methods is a good way to build constraints into the route for a REST API endpoint, which only...
Read more >Developing Python Web Applications with Flask
Flask does not provide an integrated Model (M) layer, and lets you pick your ... Instead of plain-text, you can response with an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you give us an indication, when the release will happen? Looking forward to the Async functionality 😃
Same, took me a while to pinpoint the exact issue. Solved it temporarily by using