Skip to content

Commit

Permalink
ENH/API: allow use of parallel with only one process
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Dec 15, 2022
1 parent a6c56bb commit e97f82d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyblp/utilities/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ def parallel(processes: int, use_pathos: bool = False) -> Iterator[None]:
# validate the number of processes
if not isinstance(processes, int):
raise TypeError("processes must be an int.")
if processes < 2:
raise ValueError("processes must be at least 2.")
if processes < 1:
raise ValueError("processes must be at least 1.")

# if there is only one process, do no multiprocessing
if processes == 1:
output("There is only one process, so there is no parallel processing to do.")
yield
return

# start the process pool, wait for work to be done, and then terminate it
output(f"Starting a pool of {processes} processes ...")
Expand Down

0 comments on commit e97f82d

Please sign in to comment.