Skip to content

Commit

Permalink
pythongh-101225: Fix hang when passing Pipe instances to child in mul…
Browse files Browse the repository at this point in the history
…tiprocessing

This PR uses the same backlog value when creating
a `.connection.Client` in `.resource_sharer` as is used in
`.manager`.

On macOS the default backlog (1) is small enough to cause the
socket accept queue to fill up when starting a number of children.
  • Loading branch information
ronaldoussoren committed Dec 29, 2023
1 parent 2d76be2 commit f90cd4f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/multiprocessing/resource_sharer.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _start(self):
from .connection import Listener
assert self._listener is None, "Already have Listener"
util.debug('starting listener and thread for sending handles')
self._listener = Listener(authkey=process.current_process().authkey)
self._listener = Listener(authkey=process.current_process().authkey, backlog=16)
self._address = self._listener.address
t = threading.Thread(target=self._serve)
t.daemon = True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a hang in :mod:`multiprocessing` when passing ``Pipe`` instances to
workers on macOS.

0 comments on commit f90cd4f

Please sign in to comment.