INNER CODE UNIT · Python
mp_pool
matrix-profile-foundation/matrixprofile · matrixprofile/core.py:22
def mp_pool():
"""
Utility function to get the appropriate multiprocessing
handler for Python 2 and 3.
"""
ctxt = None
if sys.version_info[0] == 2:
from contextlib import contextmanager
@contextmanager
def multiprocessing_context(*args, **kwargs):
pool = multiprocessing.Pool(*args, **kwargs)
yield pool
pool.terminate()
ctxt = multiprocessing_context
else:
ctxt = multiprocessing.Pool