Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This function should only be called once per script/notebook, at its
very beginning. The :obj:`USE_LOKY` and :obj:`USE_THREADPOOL_LIMITS`
variables may be set at any time.
"""
global USE_LOKY
start_methods = ['fork', 'spawn', 'forkserver']
if use_loky:
start_methods.extend(['loky', 'loky_int_main'])
if start_method is not None:
if start_method not in start_methods:
raise ValueError("start_method not in %s" % str(start_methods))
if use_loky:
if not _HAS_LOKY:
raise ImportError("The loky library is not installed.")
USE_LOKY = True
loky.backend.context.set_start_method(start_method)
if loky_pickler is not None:
loky.set_loky_pickler(loky_pickler)
else:
multiprocessing.set_start_method(start_method)