-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
aiohttp.ClientSession usage with Django #3357
Comments
aiohttp was never intended to work with synchronous WSGI application. |
Agreed, I believe it is better to rethink problem and do not use aiohttp in Django in first place. Depends on workload, may be just submit work to message queue from Django and pick it with async worker, where you can use aiohttp properly? |
If I have to check health of 3-5 servers in parallel (timeout 1 sex per server) during 1 django request, so aiohttp isn't good choice? |
asyncio is not a good choice if you want to call it from a synchronous WSGI application. |
You can create simple aiohttp server for this purposes and use whatever timeout you want without blocking other requests :) |
GitMate.io thinks the contributor most likely able to help you is @asvetlov. Possibly related issues are #58 (aiohttp.HttpClient), #2036 (ClientSession created in aiohttp.request() remains unclosed), #2473 (Replace aiohttp.ClientSession with aiohttp.create_session()), #2867 (aiohttp.ClientSession reconnect ), and #919 (Suggesting aiohttp.ClientSession.abort()). |
Thanks for clarification. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Hi,
I would like to use ClientSession inside my Django app. As documentations says I should have one ClientSession instance per server lifetime. My question is: where should ClientSession's initialization take place? How to perform cleanup then?
My current solution is myhttp.py module:
and in my whole app I just do:
but I don't know if it is proper approach. What is more it seems that during server shutdown cleanup function is not performed, because nothing is printed to stdout.
The text was updated successfully, but these errors were encountered: