-
-
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
Cookie expiration timers keep piling up in the asyncio event loop #1061
Comments
Agree. See also #1039 Possible solutions for Dummy jar may help in your case as you've mentioned. About adding dummy jar as default implementation for basic api -- I really don't want to invest my time into the patch. Basic API is deprecated starting from Also basic API may leak resources in case of failure under certain conditions. Current ownership schema cannot avoid it and the situation cannot be improved easy. Architectural mistake produces unsolvable bugs, sorry for that. |
keep-alive support in server has similar problem. what should really happen: we should have one "book-keeping" callback every 1-5 seconds. so we can remove expired cookies at once, same for keep-alive connections. that was in ticket for keep-alive |
The book-keepeng sources should be in |
it might be per TCPConnector, that should be enough |
|
Thanks for your reply. I'll refactor the app to use the ClientSession and a dummy jar. |
I have this same issue, except that I am not using aiohttp cookies at all. Is there a way to turn off cookies completely so expire is never called? |
Use dummy jar |
@asvetlov can you give me an example? im lost in the docs trying to figure out how |
this needs to be fixed before 1.0 |
@fafhrd91 what version are you using? |
|
Yes, when we tried to use |
Fixed by #1162 |
Hi,
I have a problem with my application since aiohttp 0.22. The application makes a lot of requests to an external REST API. It uses the aiohttp basic API and it suffers from significant slow down as the asyncio event loop gets flooded with cookie expiration timers. I know that the basic API is not effective in general as it creates a new session for every request. However, it makes no difference in my case. The external server closes connection after every request so there are no keep-alive connections and the basic API is much more comfortable in this case.
The CookieJar sets up a new expiration timer on every cookie update. In request-heavy applications, it leads to flooding the asyncio event loop with timer tasks effectively slowing down the whole process.
In my opinion, the expiration timers should be canceled on updates of existing cookies and replaced with new ones. In case of the basic API, the default CookieJar should be replaced with a dummy one to avoid scheduling the timers at all. No cookie storage is needed in case of the basic API.
Moreover, the CookieJar implementation does not need to use the timers at all. You can simply remove expired cookies when you access them.
The text was updated successfully, but these errors were encountered: