Skip to content

Commit

Permalink
Bugfix: multiprocessing.Pool is not a context manager in py 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
CensoredUsername committed Aug 17, 2024
1 parent 2d2b9c7 commit a7bb46a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion unrpyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def run_workers(worker, common_args, private_args, parallelism):

results = []
if parallelism > 1:
with Pool(parallelism) as pool:
pool = Pool(parallelism)
try:
for result in pool.imap(worker, worker_args, 1):
results.append(result)

Expand All @@ -269,6 +270,9 @@ def run_workers(worker, common_args, private_args, parallelism):

print("")

finally:
pool.close()

else:
for result in map(worker, worker_args):
results.append(result)
Expand Down

0 comments on commit a7bb46a

Please sign in to comment.