diff --git a/python/ur_simple_control/networking/client.py b/python/ur_simple_control/networking/client.py index 2cc4d94ab01abdeaf04baa530c1b3e0abf220359..a51ccea34d172ff4a48e70651353e9aa91e4eb94 100644 --- a/python/ur_simple_control/networking/client.py +++ b/python/ur_simple_control/networking/client.py @@ -65,6 +65,11 @@ def client_receiver(args, init_command, shm_name, lock): break except ConnectionRefusedError: time.sleep(0.005) + except KeyboardInterrupt: + s.close() + if args.debug_prints: + print("NETWORKING_CLIENT: caught KeyboardInterrupt, i'm out") + return if args.debug_prints: print("NETWORKING CLIENT_RECEIVER: connected to server") diff --git a/python/ur_simple_control/networking/server.py b/python/ur_simple_control/networking/server.py index 39e112ea3ed5fb0056d234c05be038b95334e730..dac395797282cab1efdb93058197710075e1f2de 100644 --- a/python/ur_simple_control/networking/server.py +++ b/python/ur_simple_control/networking/server.py @@ -20,7 +20,13 @@ def server_sender(args, init_command, queue): s.bind(host_addr) if args.debug_prints: print("NETWORKING_SERVER: server listening on", host_addr) - s.listen() + try: + s.listen() + except KeyboardInterrupt: + s.close() + if args.debug_prints: + print("NETWORKING_CLIENT: caught KeyboardInterrupt, i'm out") + return comm_socket, comm_addr = s.accept() # we're only accepting a single connection s.close()