[issue9205] Parent process hanging in multiprocessing if children terminate unexpectedly

Jesse Noller report at bugs.python.org
Thu Mar 31 15:13:16 CEST 2011


Jesse Noller <jnoller at gmail.com> added the comment:

On Thu, Mar 31, 2011 at 9:05 AM, Antoine Pitrou <report at bugs.python.org> wrote:
>
> Antoine Pitrou <pitrou at free.fr> added the comment:
>
> Possible plan for POSIX, where a connection uses a pipe() or socketpair(): exploit the fact that an endpoint becomes ready for reading (indicating EOF) when the other endpoint is closed:
>
>>>> r, w = os.pipe()
>>>> select.select([r], [], [r], 0)
> ([], [], [])
>>>> os.close(w)
>>>> select.select([r], [], [r], 0)
> ([4], [], [])
>
>>>> a, b = socket.socketpair()
>>>> select.select([b], [], [b], 0)
> ([], [], [])
>>>> a.close()
>>>> select.select([b], [], [b], 0)
> ([<socket.socket object, fd=8, family=1, type=1, proto=0>], [], [])
>
> So, each Process could have a sentinel fd in the parent process, which becomes ready when the process exits. These sentinel fds can be used in the various select() calls underlying Queue.get().
>
> (I don't understand why _multiprocessing/socket_connection.c in written in C. Rewriting it in Python would make improvements much easier)

I concur with you. The only reason it is in C is legacy; I don't see
an immediate reason why it should continue to be that way

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9205>
_______________________________________


More information about the Python-bugs-list mailing list