From dc33a0e1f295e011cc9ac89bd3a4e2f75c23c186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pekka=20Kl=C3=A4rck?= Date: Wed, 5 Mar 2014 11:43:12 +0200 Subject: [PATCH] Fix handling Ctrl-C (and signals) with Jython and IronPython Fixes #14. The fix doesn't work with Jython on Windows, though. --- src/robotremoteserver.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/robotremoteserver.py b/src/robotremoteserver.py index 53e5d06..59795dc 100644 --- a/src/robotremoteserver.py +++ b/src/robotremoteserver.py @@ -62,7 +62,6 @@ def _register_signal_handlers(self): def stop_with_signal(signum, frame): self._allow_stop = True self.stop_remote_server() - raise KeyboardInterrupt for name in 'SIGINT', 'SIGTERM', 'SIGHUP': if hasattr(signal, name): signal.signal(getattr(signal, name), stop_with_signal) @@ -79,11 +78,12 @@ def _announce_start(self, port_file=None): pf.close() def serve_forever(self): - try: - while not self._shutdown: - self.handle_request() - except KeyboardInterrupt: - pass + if hasattr(self, 'timeout'): + self.timeout = 0.5 + else: + self.socket.settimeout(0.5) + while not self._shutdown: + self.handle_request() def stop_remote_server(self): prefix = 'Robot Framework remote server at %s:%s ' % self.server_address