Merge pull request #674 from campagnola/parallelizer-fix
Prevent parallelizer leaking file handles
This commit is contained in:
commit
54f7495171
@ -195,6 +195,8 @@ class Parallelize(object):
|
|||||||
finally:
|
finally:
|
||||||
if self.showProgress:
|
if self.showProgress:
|
||||||
self.progressDlg.__exit__(None, None, None)
|
self.progressDlg.__exit__(None, None, None)
|
||||||
|
for ch in self.childs:
|
||||||
|
ch.join()
|
||||||
if len(self.exitCodes) < len(self.childs):
|
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)))
|
raise Exception("Parallelizer started %d processes but only received exit codes from %d." % (len(self.childs), len(self.exitCodes)))
|
||||||
for code in self.exitCodes:
|
for code in self.exitCodes:
|
||||||
|
@ -165,6 +165,7 @@ class Process(RemoteEventHandler):
|
|||||||
if timeout is not None and time.time() - start > timeout:
|
if timeout is not None and time.time() - start > timeout:
|
||||||
raise Exception('Timed out waiting for remote process to end.')
|
raise Exception('Timed out waiting for remote process to end.')
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
self.conn.close()
|
||||||
self.debugMsg('Child process exited. (%d)' % self.proc.returncode)
|
self.debugMsg('Child process exited. (%d)' % self.proc.returncode)
|
||||||
|
|
||||||
def debugMsg(self, msg, *args):
|
def debugMsg(self, msg, *args):
|
||||||
@ -341,6 +342,7 @@ class ForkedProcess(RemoteEventHandler):
|
|||||||
except OSError: ## probably remote process has already quit
|
except OSError: ## probably remote process has already quit
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.conn.close() # don't leak file handles!
|
||||||
self.hasJoined = True
|
self.hasJoined = True
|
||||||
|
|
||||||
def kill(self):
|
def kill(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user