Prevent parallelizer leaking file handles

This commit is contained in:
Luke Campagnola 2018-04-25 13:22:23 -07:00
parent 58a865e088
commit 465ea2d940
2 changed files with 4 additions and 0 deletions

View File

@ -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:

View File

@ -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):