Skip to content

Commit

Permalink
Fix Windows check
Browse files Browse the repository at this point in the history
and apply consistent Sphinx native param syntax.

Signed-off-by: MichaIng <[email protected]>
  • Loading branch information
MichaIng committed Dec 29, 2021
1 parent 3688022 commit 607ad40
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cheroot/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from . import errors
from ._compat import selectors
from ._compat import suppress
from ._compat import IS_WINDOWS
from .makefile import MakeFile

import six
Expand Down Expand Up @@ -185,9 +186,10 @@ def stop(self):
def run(self, expiration_interval):
"""Run the connections selector indefinitely.
Args:
expiration_interval (float): Interval, in seconds, at which
connections will be checked for expiration.
:param expiration_interval: Interval, in seconds, at which \
connections will be checked for \
expiration.
:type expiration_interval: float
Connections that are ready to process are submitted via
self.server.process_conn()
Expand All @@ -206,14 +208,22 @@ def run(self, expiration_interval):
def _run(self, expiration_interval):
"""Run connection handler loop until stop was requested.
:param expiration_interval: Interval, in seconds, at which \
connections will be checked for \
expiration.
:type expiration_interval: float
Use ``expiration_interval`` as ``select()`` timeout
to assure expired connections are closed in time.
On Windows cap the timeout to 0.05 seconds
as ``select()`` does not return when a socket is ready.
"""
last_expiration_check = time.time()
select_timeout = min(expiration_interval, 0.05 if IS_WINDOWS else expiration_interval)
if IS_WINDOWS:
select_timeout = min(expiration_interval, 0.05)
else:
select_timeout = expiration_interval

while not self._stop_requested:
try:
Expand Down

0 comments on commit 607ad40

Please sign in to comment.