Skip to content

Commit 70102a9

Browse files
chore: fix multithreading log test not being able to pickle local worker function (#423)
This PR is fixing failing unit test `test_multi_process` when running `poetry run pytest tests/unit`. ``` tests/unit/test_log.py:119: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py:121: in start self._popen = self._Popen(self) /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py:224: in _Popen return _default_context.get_context().Process._Popen(process_obj) /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py:284: in _Popen return Popen(process_obj) /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py:32: in __init__ super().__init__(process_obj) /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py:19: in __init__ self._launch(process_obj) /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py:47: in _launch reduction.dump(process_obj, fp) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obj = <Process name='Process-1' parent=76837 initial>, file = <_io.BytesIO object at 0x10fe45810>, protocol = None def dump(obj, file, protocol=None): '''Replacement for pickle.dump() using ForkingPickler.''' > ForkingPickler(file, protocol).dump(obj) E AttributeError: Can't pickle local object 'TestLogs.test_multi_process.<locals>.worker' /usr/local/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py:60: AttributeError ```
1 parent 32e5c1b commit 70102a9

File tree

2 files changed

+125
-136
lines changed

2 files changed

+125
-136
lines changed

0 commit comments

Comments
 (0)