Skip to content

Commit dc33a0e

Browse files
committed
Fix handling Ctrl-C (and signals) with Jython and IronPython
Fixes robotframework#14. The fix doesn't work with Jython on Windows, though.
1 parent c0e8e53 commit dc33a0e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/robotremoteserver.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def _register_signal_handlers(self):
6262
def stop_with_signal(signum, frame):
6363
self._allow_stop = True
6464
self.stop_remote_server()
65-
raise KeyboardInterrupt
6665
for name in 'SIGINT', 'SIGTERM', 'SIGHUP':
6766
if hasattr(signal, name):
6867
signal.signal(getattr(signal, name), stop_with_signal)
@@ -79,11 +78,12 @@ def _announce_start(self, port_file=None):
7978
pf.close()
8079

8180
def serve_forever(self):
82-
try:
83-
while not self._shutdown:
84-
self.handle_request()
85-
except KeyboardInterrupt:
86-
pass
81+
if hasattr(self, 'timeout'):
82+
self.timeout = 0.5
83+
else:
84+
self.socket.settimeout(0.5)
85+
while not self._shutdown:
86+
self.handle_request()
8787

8888
def stop_remote_server(self):
8989
prefix = 'Robot Framework remote server at %s:%s ' % self.server_address

0 commit comments

Comments
 (0)