Skip to content

Commit

Permalink
Call close() and join() on multiprocessing.Pool()
Browse files Browse the repository at this point in the history
According to the documentation
https://coverage.readthedocs.io/en/latest/subprocess.html#using-multiprocessing
a `pool` needs to be closed and joined, even inside a `with` block.

According to
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool
the `Pool` class calls `terminate()` whenever the context manager calls `pool.__exit()__`
This will terminate the worker processes immediately, and apparently `coverage` won't have
enough time to record its coverage measurements.

So this change is only needed to measure the coverage properly.
  • Loading branch information
phiwuu committed Feb 12, 2025
1 parent ee2c98a commit a74c7ae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lobster/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,7 @@ def execute(self):
for new_ok, new_items in pool.imap(pfun, work_list, 4):
ok &= new_ok
items += new_items
pool.close()
pool.join()

return self.write_output(ok, options, items)

0 comments on commit a74c7ae

Please sign in to comment.