Skip to content

Commit

Permalink
BUG: handle pickling of SymPy's global parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Apr 11, 2023
1 parent ddb2f42 commit 4e4f346
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pyblp/utilities/basics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Basic functionality."""

import contextlib
import copyreg
import functools
import inspect
import multiprocessing.pool
Expand Down Expand Up @@ -80,6 +81,12 @@ def parallel(processes: int, use_pathos: bool = False) -> Iterator[None]:
yield
return

# register hooks for pickling and unpickling SymPy's global parameters object
from sympy.core.parameters import _global_parameters
unpickle_global_parameters = lambda x: _global_parameters(**x)
pickle_global_parameters = lambda x: (unpickle_global_parameters, (x.__dict__,))
copyreg.pickle(_global_parameters, pickle_global_parameters)

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

0 comments on commit 4e4f346

Please sign in to comment.