Merge pull request #674 from campagnola/parallelizer-fix

Prevent parallelizer leaking file handles
This commit is contained in:
Luke Campagnola 2018-04-25 16:12:35 -07:00 committed by GitHub
commit 54f7495171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):