diff options
author | Robert Guo <robert.guo@10gen.com> | 2019-07-01 18:00:47 -0400 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2019-07-03 13:07:10 -0400 |
commit | f747b5477375197f4bef6e2e06899f7f974b9151 (patch) | |
tree | 4167cf606d8b1db3e0feb54c3d610bfaa5df35f9 | |
parent | 990b2ef30d7b8fa4db6af6d79da80e3664df9c21 (diff) | |
download | mongo-f747b5477375197f4bef6e2e06899f7f974b9151.tar.gz |
SERVER-40702 wait for processes to exit on KeyboardInterrupt in resmoke
-rw-r--r-- | buildscripts/resmokelib/testing/executor.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/buildscripts/resmokelib/testing/executor.py b/buildscripts/resmokelib/testing/executor.py index ca8dc9a9d5b..21a1d12e128 100644 --- a/buildscripts/resmokelib/testing/executor.py +++ b/buildscripts/resmokelib/testing/executor.py @@ -196,12 +196,20 @@ class TestSuiteExecutor(object): # pylint: disable=too-many-instance-attributes except (KeyboardInterrupt, SystemExit): interrupt_flag.set() user_interrupted = True - else: - # Only wait for all the Job instances if not interrupted by the user. - self.logger.debug("Waiting for threads to complete") + + wait_secs = 2.0 + self.logger.debug("Waiting for threads to complete") + + timer = threading.Timer(wait_secs, self._log_timeout_warning, args=[wait_secs]) + timer.daemon = True + timer.start() + try: for thr in threads: thr.join() - self.logger.debug("Threads are completed!") + finally: + timer.cancel() + + self.logger.debug("Threads are completed!") reports = [job.report for job in self._jobs] combined_report = _report.TestReport.combine(*reports) @@ -316,3 +324,9 @@ class TestSuiteExecutor(object): # pylint: disable=too-many-instance-attributes queue.put(queue_elem) return queue + + def _log_timeout_warning(self, seconds): + """Log a message if any thread fails to terminate after `seconds`.""" + self.logger.warning( + '*** Still waiting for processes to terminate after %s seconds. Try using ctrl-\\ ' + 'to send a SIGQUIT on Linux or ctrl-c again on Windows ***', seconds) |