Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug causing pipe FDs to leak #74

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

join() here blocks until the process has ended, but if it's in _completed it already ended. This was unnecessary.

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