gh-101225: Fix hang when passing Pipe instances to child in multiprocessing#113567
Conversation
…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.
|
Is there any reason to keep the backlog value at 16? Increasing the backlog at both locations (this one and the one in manager.py) to 64 would fix #87934 on my laptop. |
|
I've increased the backlog parameter in both manager.py and resource_sharer.py. As mentioned in my previous message this will also fix #87934. |
gpshead
left a comment
There was a problem hiding this comment.
I have no problem with this change, we may as well have a larger listen queue - systems are large enough these days... but I'm wary of calling it a "fix". It feels like this just papers over the problem and leaves it to reappear later as machines grow, or perhaps under heavy system load.
If something can hang due to a connection failure not being to a retry rather than losing track of the task it was supposed to accomplish (if the bug report summary is accurate)... the real bug lurks there, rather than just the queue depth?
Yeah, I'm being a bit optimistic here. There is a race condition between the processes creating connections and the proces waiting for connections. To be honest I don't understand why a backlog of 1 in In #87934 I added a retry loop that also fixes the issue (for |
|
I've updated the new entry, it is now clearer about what changed and no longer claims this definitely fixes something. |
|
Thanks @ronaldoussoren for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
…cessing.connection.Listener (pythonGH-113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them. (cherry picked from commit c7d59bd) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
…cessing.connection.Listener (pythonGH-113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them. (cherry picked from commit c7d59bd) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
|
GH-114018 is a backport of this pull request to the 3.12 branch. |
|
GH-114019 is a backport of this pull request to the 3.11 branch. |
…ocessing.connection.Listener (GH-113567) (#114018) gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (GH-113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them. (cherry picked from commit c7d59bd) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
…ocessing.connection.Listener (GH-113567) (#114019) gh-101225: Increase the socket backlog when creating a multiprocessing.connection.Listener (GH-113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them. (cherry picked from commit c7d59bd) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
…cessing.connection.Listener (python#113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them.
…cessing.connection.Listener (python#113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them.
…cessing.connection.Listener (python#113567) Increase the backlog for multiprocessing.connection.Listener` objects created by `multiprocessing.manager` and `multiprocessing.resource_sharer` to significantly reduce the risk of getting a connection refused error when creating a `multiprocessing.connection.Connection` to them.
This PR uses the same backlog value when creating
a
.connection.Clientin.resource_shareras 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.