Skip to content

Commit

Permalink
Fix infinite callback loop when used with async-solipsism
Browse files Browse the repository at this point in the history
If the keepalive handler is called too soon, it reschedules itself. The
test used `now <= close_time`, which means that an exactly on-time
notification is treated as "too soon", causing an automatic
rescheduling. For real systems the time will eventually advance and
break the loop, but with async-solipsism, time doesn't advance until
there is some reason to sleep and the loop is infinite.

Closes aio-libs#10149.
  • Loading branch information
bmerry committed Dec 9, 2024
1 parent 6200513 commit 957a3ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def _process_keepalive(self) -> None:
loop = self._loop
now = loop.time()
close_time = self._next_keepalive_close_time
if now <= close_time:
if now < close_time:
# Keep alive close check fired too early, reschedule
self._keepalive_handle = loop.call_at(close_time, self._process_keepalive)
return
Expand Down

0 comments on commit 957a3ea

Please sign in to comment.