Skip to content

Commit cc9cac1

Browse files
committed
Avoid the multiprocessing forkserver method
Python 3.14 changed the default multiprocessing method for POSIX (sans macOS) from fork to forkserver. This causes errors like: TypeError: cannot pickle 'select.epoll' object when serializing dict item '_poller' when serializing pyftpdlib.ioloop.Epoll state when serializing pyftpdlib.ioloop.Epoll object when serializing dict item 'ioloop' when serializing pyftpdlib.servers.MultiprocessFTPServer state when serializing pyftpdlib.servers.MultiprocessFTPServer object when serializing tuple item 0 when serializing method reconstructor arguments when serializing method object when serializing dict item '_target' when serializing multiprocessing.context.Process state when serializing multiprocessing.context.Process object See python/cpython#125714
1 parent c4ceda4 commit cc9cac1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pyftpdlib/servers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,13 @@ class MultiprocessFTPServer(_SpawnerBase):
579579

580580
_lock = multiprocessing.Lock()
581581
_exit = multiprocessing.Event()
582+
# Python 3.14 changed the non-macOS POSIX default to forkserver
583+
# but the code in this module does not work with it
584+
# See https://github.com/python/cpython/issues/125714
585+
if multiprocessing.get_start_method() == 'forkserver':
586+
_mp_context = multiprocessing.get_context(method='fork')
587+
else:
588+
_mp_context = multiprocessing.get_context()
582589

583590
def _start_task(self, *args, **kwargs):
584-
return multiprocessing.Process(*args, **kwargs)
591+
return self._mp_context.Process(*args, **kwargs)

0 commit comments

Comments
 (0)