From 465ea2d940e6ef5b9b55b8556506a345265616a4 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 25 Apr 2018 13:22:23 -0700 Subject: [PATCH] Prevent parallelizer leaking file handles --- pyqtgraph/multiprocess/parallelizer.py | 2 ++ pyqtgraph/multiprocess/processes.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pyqtgraph/multiprocess/parallelizer.py b/pyqtgraph/multiprocess/parallelizer.py index 86298023..ef00be7c 100644 --- a/pyqtgraph/multiprocess/parallelizer.py +++ b/pyqtgraph/multiprocess/parallelizer.py @@ -195,6 +195,8 @@ class Parallelize(object): finally: if self.showProgress: self.progressDlg.__exit__(None, None, None) + for ch in self.childs: + ch.join() if len(self.exitCodes) < len(self.childs): raise Exception("Parallelizer started %d processes but only received exit codes from %d." % (len(self.childs), len(self.exitCodes))) for code in self.exitCodes: diff --git a/pyqtgraph/multiprocess/processes.py b/pyqtgraph/multiprocess/processes.py index 1be7e50b..0a372ef0 100644 --- a/pyqtgraph/multiprocess/processes.py +++ b/pyqtgraph/multiprocess/processes.py @@ -165,6 +165,7 @@ class Process(RemoteEventHandler): if timeout is not None and time.time() - start > timeout: raise Exception('Timed out waiting for remote process to end.') time.sleep(0.05) + self.conn.close() self.debugMsg('Child process exited. (%d)' % self.proc.returncode) def debugMsg(self, msg, *args): @@ -341,6 +342,7 @@ class ForkedProcess(RemoteEventHandler): except OSError: ## probably remote process has already quit pass + self.conn.close() # don't leak file handles! self.hasJoined = True def kill(self):