[pypy-dev] Dead loop occurs when using python-daemon and multiprocessing together in PyPy 4.0.1

Armin Rigo arigo at tunes.org
Wed Dec 23 12:24:54 EST 2015


Hi Maciej,

On Wed, Dec 23, 2015 at 3:48 PM, Maciej Fijalkowski <fijall at gmail.com>
wrote:

> I bet the difference is due to "we see more FDs in pypy". If you close the
> correct FD in CPython, it would break too I presume? Or is there special
> code to handle that?
>

There is special code to handle that in CPython.  It is actually very
carefully checking that the FD is still open *and* still pointing to what
it used to.  See Python/random.c.

Just thinking aloud: what could occur here is that the forked process
reopens an unrelated file at this descriptor, and then our os.urandom()
tries to read from it---and, as a guess, the file happens to be a socket
opened in non-blocking mode, and our implementation of os.urandom() gets 0
bytes and keeps trying to get more, which throws it into an infinite loop.

It seems it would be a good idea to copy the careful behavior of CPython.
(There used to be another case of file descriptor kept open internally, in
rpython/rtyper/lltypesystem/llarena.py for /dev/zero, but this is gone.)


A bientôt,

Armin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20151223/9208815e/attachment.html>


More information about the pypy-dev mailing list