Skip to content

Commit

Permalink
[Typing][Fix] Ensure all workers are running complete before pool ter…
Browse files Browse the repository at this point in the history
…minate (#65199)
  • Loading branch information
megemini authored Jun 15, 2024
1 parent 2e66576 commit 8261cde
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tools/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,15 @@ def get_test_results(
)

test_results = []
pool = multiprocessing.Pool(initializer=init_worker)
try:
test_results = pool.starmap(type_checker.run, codeblocks)

except KeyboardInterrupt:
pool.terminate()
pool.join()
with multiprocessing.Pool(initializer=init_worker) as pool:
try:
test_results = pool.starmap(type_checker.run, codeblocks)
except KeyboardInterrupt:
pool.terminate()
else:
pool.close()
finally:
pool.join()

return list(test_results)

Expand Down

0 comments on commit 8261cde

Please sign in to comment.