STINNER Victor added the comment: > I have seen complains from e.g. Tarek that os.urandom() fails under high > load: https://twitter.com/tarek_ziade/status/362281268215418880
dev_urandom_python() should handle ENFILE and ENOENT differently to raise a different exception. Or it should always call PyErr_SetFromErrno(PyExc_OSError); ? Can tarek tell us more about its usecases: is he directly calling os.urandom() or does he use the random module? How many threads? > How about os.urandom() uses a persistent file descriptor? os.urandom() is called at Python startup to generate a "secret key" for random hash. If the file descriptor is never closed, the next file descriptor will be 4 instead of the expect 3. Always keeping an internal file descriptor open may have unexpected effects like leaking a file descriptor to a child process... (see the PEP 446, not implemented yet). I'm ok to keep a fd open if the user controls the lifetime of the object (lifetime of the fd). For example, I expect that rng = SystemRandom() opens /dev/urandom when the object is created, and closes it when the object is destroyed. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18756> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com