summaryrefslogtreecommitdiff
path: root/scripts/LocalDriver.py
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-09-01 18:40:29 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-09-01 18:40:29 +0200
commit17ae6083282edf8dd960de424021cde7db613664 (patch)
treea8f8a1589427dd6e17a6fec37d6aabc34ec3d77d /scripts/LocalDriver.py
parentFixed ICE-8471 - better warning for spurious selector wakeup (diff)
downloadice-17ae6083282edf8dd960de424021cde7db613664.tar.bz2
ice-17ae6083282edf8dd960de424021cde7db613664.tar.xz
ice-17ae6083282edf8dd960de424021cde7db613664.zip
Fixed ICE-8396 - improved allTests.py handling of Ctrl-C interrupts
Diffstat (limited to 'scripts/LocalDriver.py')
-rw-r--r--scripts/LocalDriver.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/scripts/LocalDriver.py b/scripts/LocalDriver.py
index 87b10a31955..160c571b3a9 100644
--- a/scripts/LocalDriver.py
+++ b/scripts/LocalDriver.py
@@ -7,7 +7,7 @@
#
# **********************************************************************
-import sys, os, time
+import sys, os, time, threading
from Util import *
isPython2 = sys.version_info[0] == 2
@@ -63,6 +63,10 @@ class Executor:
with self.lock:
return self.interrupted
+ def setInterrupt(self, value):
+ with self.lock:
+ self.interrupted = value
+
def runTestSuites(self, driver, total, results, mainThread=False):
while True:
item = self.get(total, mainThread)
@@ -76,7 +80,8 @@ class Executor:
try:
testsuite.run(current)
except KeyboardInterrupt:
- raise
+ if mainThread:
+ raise
except:
pass
finally:
@@ -149,6 +154,8 @@ class Executor:
self.interrupted = True
if threads:
print("Terminating (waiting for worker threads to terminate)...")
+ else:
+ print("")
raise
finally:
#
@@ -557,7 +564,19 @@ class LocalDriver(Driver):
self.runner.runClientSide(client, current, host)
success = True
finally:
- self.runner.stopServerSide(server, current, success)
+ #
+ # We start a thread to stop the servers, this ensures that stopServerSide doesn't get
+ # interrupted by potential KeyboardInterrupt exceptions which could leave some servers
+ # behind.
+ #
+ t=threading.Thread(target = lambda: self.runner.stopServerSide(server, current, success))
+ t.start()
+ while True:
+ try:
+ t.join()
+ break
+ except KeyboardInterrupt:
+ pass # Ignore keyboard interrupts
def runTestCase(self, current):
if self.cross or self.allCross:
@@ -583,6 +602,9 @@ class LocalDriver(Driver):
def isInterrupted(self):
return self.executor.isInterrupted()
+ def setInterrupt(self, value):
+ self.executor.setInterrupt(value)
+
def getTestPort(self, portnum):
# Return a port number in the range 14100-14199 for the first thread, 14200-14299 for the
# second thread, etc.