-
-
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
Infinite loop when used with async_solipsism #10149
Comments
Changing it from |
Thanks, that was my feeling too but it's good to have confirmation. I'll send a PR tomorrow. |
At request of @bdraco
Describe the bug
async_solipsism is an event loop that uses fake time - good for unit tests. The keepalive logic in aiohttp assumes that loop.call_at will always call the handler strictly later than the requested time, but that doesn't hold for the idealised time source in async_solipsism. The net result is that tests using async_solipsism can get stuck in an infinite loop where aiohttp keeps re-submitting the keepalive handler.
To Reproduce
Expected behavior
The test should succeed.
Logs/tracebacks
Python Version
aiohttp Version
3.11.10
multidict Version
6.0.5
propcache Version
0.2.0
yarl Version
1.18.0
OS
Ubuntu 24.04
Related component
Server
Additional context
The issue is in this line. If the handler fires exactly on time, this check treats it as too early, and it is queued to run again. It will keep getting re-submitted until the clock ticks past
close_time
. With a real system that's likely to happen immediately (since the number of instructions that can run per clock tick is pretty small), but with the artificial time in async_solipsism (and probably any similar source of mock time), time doesn't flow until there is something to sleep for, and this becomes an infinite loop.I'm happy to supply a patch. The fix itself is easy (change
<=
to<
), but let me know what you recommend for regression testing. Would it be reasonable to make async_solipsism a dev dependency of aiohttp so that it can be used in a regression test?Code of Conduct
The text was updated successfully, but these errors were encountered: