Skip to content

Commit

Permalink
fix server keep-alive timer #1955
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jun 18, 2017
1 parent ca575f9 commit 4a99b3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Changes

- Make sure cleanup signal is sent if startup signal has been sent #1959

-
- Fixed server keep-alive handler, could cause 100% cpu utilization #1955

-

Expand Down
4 changes: 4 additions & 0 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ def strtime(self):
def loop_time(self):
return self._loop_time

@property
def interval(self):
return self._interval


def _weakref_handle(info):
ref, name = info
Expand Down
3 changes: 2 additions & 1 deletion aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ def _process_keepalive(self):

# all handlers in idle state
if len(self._request_handlers) == len(self._waiters):
# time_service.loop_time is ceiled to 1.0, so we check 2 intervals
now = self._time_service.loop_time
if now + 1.0 > next:
if (now + self._time_service.interval * 2) > next:
self.force_close(send_last_heartbeat=True)
return

Expand Down

0 comments on commit 4a99b3a

Please sign in to comment.