Skip to content

Commit

Permalink
fix: cleanup thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Louis Fuchs committed Jul 14, 2022
1 parent 9e2db65 commit fec982e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions document_merge_service/api/tests/test_unoconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,21 @@ def test_fork_load(capsys):
test_files += [Path(load, "3.docx")] * count
test_files += [Path(load, "4.docx")] * count
random.shuffle(test_files)
pool = ThreadPool(8)
with capsys.disabled():
sys.stdout.write(" Loadtest: ")
sys.stdout.flush()
for result in pool.imap(try_fork_load, enumerate(test_files)):
try:
pool = ThreadPool(8)
with capsys.disabled():
sys.stdout.write(".")
sys.stdout.write(" Loadtest: ")
sys.stdout.flush()
if isinstance(result, Exception): # pragma: no cover
raise result
elif not result.stdout.startswith(b"%PDF"): # pragma: no cover
raise ValueError(result)
with capsys.disabled():
sys.stdout.write("done")
for result in pool.imap(try_fork_load, enumerate(test_files)):
with capsys.disabled():
sys.stdout.write(".")
sys.stdout.flush()
if isinstance(result, Exception): # pragma: no cover
raise result
elif not result.stdout.startswith(b"%PDF"): # pragma: no cover
raise ValueError(result)
with capsys.disabled():
sys.stdout.write("done")
finally:
pool.close()
pool.join()

0 comments on commit fec982e

Please sign in to comment.