[Lldb-commits] [lldb] r254024 - Make swig_bot server support Ctrl+C

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 24 13:35:41 PST 2015


Author: zturner
Date: Tue Nov 24 15:35:40 2015
New Revision: 254024

URL: http://llvm.org/viewvc/llvm-project?rev=254024&view=rev
Log:
Make swig_bot server support Ctrl+C

Modified:
    lldb/trunk/scripts/swig_bot.py
    lldb/trunk/scripts/swig_bot_lib/server.py

Modified: lldb/trunk/scripts/swig_bot.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/swig_bot.py?rev=254024&r1=254023&r2=254024&view=diff
==============================================================================
--- lldb/trunk/scripts/swig_bot.py (original)
+++ lldb/trunk/scripts/swig_bot.py Tue Nov 24 15:35:40 2015
@@ -57,6 +57,9 @@ if __name__ == "__main__":
         else:
             logging.error("Unknown mode specified.  Expected client or server.")
             sys.exit(-1)
+    except KeyboardInterrupt as e:
+        logging.info("Ctrl+C received.  Shutting down...")
+        sys.exit(-1)
     except Exception as e:
         error = traceback.format_exc()
         logging.error("An error occurred running swig-bot.")

Modified: lldb/trunk/scripts/swig_bot_lib/server.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/swig_bot_lib/server.py?rev=254024&r1=254023&r2=254024&view=diff
==============================================================================
--- lldb/trunk/scripts/swig_bot_lib/server.py (original)
+++ lldb/trunk/scripts/swig_bot_lib/server.py Tue Nov 24 15:35:40 2015
@@ -13,6 +13,7 @@ from __future__ import print_function
 import argparse
 import logging
 import os
+import select
 import socket
 import struct
 import sys
@@ -53,16 +54,23 @@ def initialize_listening_socket(options)
 
 def accept_once(sock, options):
     logging.debug("Waiting for connection...")
-    client, addr = sock.accept()
-    logging.info("Received connection from {}".format(addr))
-    data_size = struct.unpack("!I", sockutil.recvall(client, 4))[0]
-    logging.debug("Expecting {} bytes of data from client".format(data_size))
-    data = sockutil.recvall(client, data_size)
-    logging.info("Received {} bytes of data from client".format(len(data)))
-
-    logging.info("Sending {} byte response".format(len(data)))
-    client.sendall(struct.pack("!I", len(data)))
-    client.sendall(data)
+    while True:
+        rlist, wlist, xlist = select.select([sock], [], [], 0.5)
+        if not rlist:
+            continue
+
+        client, addr = sock.accept()
+        logging.info("Received connection from {}".format(addr))
+        data_size = struct.unpack("!I", sockutil.recvall(client, 4))[0]
+        logging.debug("Expecting {} bytes of data from client"
+                      .format(data_size))
+        data = sockutil.recvall(client, data_size)
+        logging.info("Received {} bytes of data from client"
+                     .format(len(data)))
+
+        logging.info("Sending {} byte response".format(len(data)))
+        client.sendall(struct.pack("!I", len(data)))
+        client.sendall(data)
 
 def accept_loop(sock, options):
     while True:




More information about the lldb-commits mailing list