-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
I encountered pickling issue (originally when building redis for Fedora Linux) when a multiprocessing.Process is started with target being a function defined in a function. Python 3.14.0a1 fails with the PicklingError.
This has happened in at least 5 packages we've got in Fedora, typically in testing functions: redis, etcd, iniparse, readability-lxml, satyr.
The default method in Linux has changed per What's new document (https://docs.python.org/3.14/whatsnew/3.14.html#multiprocessing). Is this expected? Is this a regression? In Python 3.13 there's no issue with this code.
import multiprocessing
def main():
def func():
pass
proc = multiprocessing.Process(target=func)
proc.start()
proc.join(3)
return proc.exitcode
if __name__ == '__main__':
print(main())
Python 3.13:
0
Python 3.14.0a1:
Traceback (most recent call last):
File "<python-input-0>", line 12, in <module>
print(main())
~~~~^^
File "<python-input-0>", line 8, in main
proc.start()
~~~~~~~~~~^^
File "/usr/lib64/python3.14/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
~~~~~~~~~~~^^^^^^
File "/usr/lib64/python3.14/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/context.py", line 300, in _Popen
return Popen(process_obj)
File "/usr/lib64/python3.14/multiprocessing/popen_forkserver.py", line 35, in __init__
super().__init__(process_obj)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/popen_fork.py", line 20, in __init__
self._launch(process_obj)
~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/popen_forkserver.py", line 47, in _launch
reduction.dump(process_obj, buf)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.14/multiprocessing/reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
_pickle.PicklingError: Can't pickle local object <function main.<locals>.func at 0x7f721468a8d0>
when serializing dict item '_target'
when serializing multiprocessing.context.Process state
when serializing multiprocessing.context.Process object
CPython versions tested on:
3.14, main branch
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error