Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #332 from ariddell/feature/issue-249
Browse files Browse the repository at this point in the history
Avoid using context manager with multiprocessing.Pool
  • Loading branch information
ariddell authored May 1, 2017
2 parents c6ad85d + 634d937 commit 2316708
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pystan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def _map_parallel(function, args, n_jobs):
if multiprocessing and int(n_jobs) not in (0, 1):
if n_jobs == -1:
n_jobs = None
with multiprocessing.Pool(processes=n_jobs) as pool:
try:
pool = multiprocessing.Pool(processes=n_jobs)
map_result = pool.map(function, args)
finally:
pool.close()
pool.join()
else:
map_result = list(map(function, args))
return map_result
Expand Down

0 comments on commit 2316708

Please sign in to comment.