Skip to content

Commit

Permalink
♲ Stop handling EINTR around time.sleep()
Browse files Browse the repository at this point in the history
`IOError` is an alias of `OSError` since Python 3.3. Python 3 also
indroduced a new exception `InterruptedError` which represents
`EINTR`. The `time.sleep()` call could raise

    IOError: [Errno 4] Interrupted function call

on KBInt under Python 2, which would be `InterruptedError` under
Python 3 but it's not raised anymore post PEP 475 that was implemented
in Python 3.5. So it does not actually need to be handled in modern
runtimes.

Refs:
* https://stackoverflow.com/a/52613818/595220
* https://peps.python.org/pep-0475/
* python/cpython#56671
* https://stackoverflow.com/a/38258781/595220
* https://docs.python.org/3/library/exceptions.html#InterruptedError
* python/cpython#36893
  • Loading branch information
webknjaz committed Mar 23, 2024
1 parent e8471f4 commit f822e33
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions cheroot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,9 +1729,7 @@ def safe_start(self):
"""Run the server forever, and stop it cleanly on exit."""
try:
self.start()
except (KeyboardInterrupt, IOError):
# The time.sleep call might raise
# "IOError: [Errno 4] Interrupted function call" on KBInt.
except KeyboardInterrupt:

Check warning on line 1732 in cheroot/server.py

View check run for this annotation

Codecov / codecov/patch

cheroot/server.py#L1732

Added line #L1732 was not covered by tests
self.error_log('Keyboard Interrupt: shutting down')
self.stop()
raise
Expand Down

0 comments on commit f822e33

Please sign in to comment.