Skip to content

Commit

Permalink
Avoid the multiprocessing forkserver method (#656)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hroncok authored Nov 22, 2024
1 parent c4ceda4 commit d90297a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pyftpdlib/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,13 @@ class MultiprocessFTPServer(_SpawnerBase):

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

def _start_task(self, *args, **kwargs):
return multiprocessing.Process(*args, **kwargs)
return self._mp_context.Process(*args, **kwargs)

0 comments on commit d90297a

Please sign in to comment.