You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--------------------------------------------------------------------------------
LokyProcess-2 failed with traceback:
--------------------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/backend/popen_loky_posix.py", line 198, in <module>
process_obj = pickle.load(from_parent)
AttributeError: Can't get attribute 'initializer' on <module 'loky.backend.popen_loky_posix' from '/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/backend/popen_loky_posix.py'>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
LokyProcess-1 failed with traceback:
--------------------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/backend/popen_loky_posix.py", line 198, in <module>
process_obj = pickle.load(from_parent)
AttributeError: Can't get attribute 'initializer' on <module 'loky.backend.popen_loky_posix' from '/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/backend/popen_loky_posix.py'>
--------------------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/louis/Documents/test/scripts/multi_loky.py", line 31, in <module>
assert executor.submit(test_initializer).result() == 'initialized'
File "/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/_base.py", line 431, in result
return self.__get_result()
File "/Users/louis/Documents/venv_flax_py3/lib/python3.6/site-packages/loky/_base.py", line 382, in __get_result
raise self._exception
loky.process_executor.BrokenProcessPool: A process in the executor was terminated abruptly while the future was running or pending.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this.
I can indeed reproduce. Here, the initializer is not picklable as the main module is not initialized. It would need to be serialized with cloudpickle.
A quick fix would be to use the following script, and launch it with the environment variable LOKY_PICKLER='pickle'.
from time import sleep
from loky import get_reusable_executor
INITIALIZER_STATUS = 'uninitialized'
def initializer(x):
global INITIALIZER_STATUS
INITIALIZER_STATUS = x
def return_initializer_status(delay=0):
sleep(delay)
global INITIALIZER_STATUS
return INITIALIZER_STATUS
if __name__ == '__main__':
executor = get_reusable_executor(
max_workers=2, initializer=initializer, initargs=('initialized',),
context="loky_init_main")
assert executor.submit(return_initializer_status).result() == 'initialized'
# With reuse=True, the executor use the same initializer
executor = get_reusable_executor(max_workers=4, reuse=True)
for x in executor.map(return_initializer_status, [.5] * 4):
assert x == 'initialized'
# With reuse='auto', the initializer is not used anymore as a new executor
# is created.
executor = get_reusable_executor(max_workers=4, context='loky_init_main')
for x in executor.map(return_initializer_status, [.1] * 4):
assert x == 'uninitialized'
After investigating, the issue here is that we do not handle consistently the pickling of the initializer in loky. The fix is non-trivial as it is linked to cloudpipe/cloudpickle#187.
I run example at https://loky.readthedocs.io/en/stable/auto_examples/reuseable_executor.html#sphx-glr-download-auto-examples-reuseable-executor-py but error occur
The text was updated successfully, but these errors were encountered: