Skip to content

Commit

Permalink
Merge pull request #74 from jealouscloud/pipeleak_fix
Browse files Browse the repository at this point in the history
Fix a bug causing pipe FDs to leak
  • Loading branch information
ploxiln authored Feb 27, 2023
2 parents 97a0c04 + cdc597d commit 8e61a2b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fabric/job_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ def _advance_the_queue():
if self._debug:
print("Job queue found finished proc: %s." % job.name)
done = self._running.pop(id)
self._completed.append(done)
self._completed.append((done.name, done.exitcode))
if hasattr(done, 'close') and callable(done.close):
done.close()
# multiprocessing.Process.close() added in Python-3.7
# for older versions of python, GC will have to do
del done

if self._debug:
print("Job queue has %d running." % len(self._running))
Expand All @@ -157,9 +162,6 @@ def _advance_the_queue():
if self._debug:
print("Job queue finished.")

for job in self._completed:
job.join()

self._finished = True

# Each loop pass, try pulling results off the queue to keep its
Expand All @@ -175,9 +177,9 @@ def _advance_the_queue():
self._fill_results(results)

# Attach exit codes now that we're all done & have joined all jobs
for job in self._completed:
for job_name, exit_code in self._completed:
if isinstance(job, Process):
results[job.name]['exit_code'] = job.exitcode
results[job_name]['exit_code'] = exit_code

return results

Expand Down

0 comments on commit 8e61a2b

Please sign in to comment.