Skip to content

Commit

Permalink
Merge pull request #236 from jorana/patch-2
Browse files Browse the repository at this point in the history
Change processor to prevent errors in python>=3.7
  • Loading branch information
JelleAalbers committed Mar 2, 2020
2 parents 9116d2b + 336a91a commit 007b0bc
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions strax/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,33 +223,12 @@ def iter(self):
m.cleanup()
self.log.debug("Closing threads completed")

# It would be great if python had a timeout for Executor.shutdown!
self.log.debug("Closing executors")
if self.thread_executor is not None:
self.thread_executor.shutdown(wait=False)

self.thread_executor.shutdown(wait=True)
if self.process_executor not in [None, self.thread_executor]:
# Unfortunately there is no wait=timeout option, so we have to
# roll our own
pids = self.process_executor._processes.keys()
self.process_executor.shutdown(wait=False)

t0 = time.time()
while time.time() < t0 + 20:
if all([not psutil.pid_exists(pid) for pid in pids]):
break
self.log.info("Waiting for subprocesses to end")
time.sleep(2)
else:
self.log.warning("Subprocesses failed to terminate, "
"resorting to brute force killing")
for pid in pids:
try:
os.kill(pid, signal.SIGTERM)
except ProcessLookupError:
# Didn't exist
pass
self.log.info("Sent SIGTERM to all subprocesses")

self.process_executor.shutdown(wait=True)
self.log.debug("Closing executors completed")

if traceback is not None:
Expand Down

0 comments on commit 007b0bc

Please sign in to comment.