From f822e33e4d010ac2caafc8a2f36bb24a6778e08b Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 21 Mar 2024 19:47:50 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=B2=20Stop=20handling=20`EINTR`=20around?= =?UTF-8?q?=20`time.sleep()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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/ * https://github.com/python/cpython/issues/56671 * https://stackoverflow.com/a/38258781/595220 * https://docs.python.org/3/library/exceptions.html#InterruptedError * https://github.com/python/cpython/issues/36893 --- cheroot/server.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cheroot/server.py b/cheroot/server.py index 7615b5ef83..ae6bc5fab3 100644 --- a/cheroot/server.py +++ b/cheroot/server.py @@ -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: self.error_log('Keyboard Interrupt: shutting down') self.stop() raise