[New-bugs-announce] [issue18756] os.urandom() fails under high load

Christian Heimes report at bugs.python.org
Fri Aug 16 17:21:38 CEST 2013

New submission from Christian Heimes:

I have seen complains from e.g. Tarek that os.urandom() fails under high load: https://twitter.com/tarek_ziade/status/362281268215418880

The problem is caused by file descriptor limits. os.urandom() opens /dev/urandom for every call. How about os.urandom() uses a persistent file descriptor? That should eliminate the error. It may alsos speed up os.urandom() because a persistent FD gets rid of open() and close() syscalls.

* open /dev/urandom on first call of os.urandom() and store the fd in a static var
* invalidate, close fd on read() -> EINVAL; open /dev/urandom again
* close fd when interpreter shuts down

components: Extension Modules
messages: 195338
nosy: christian.heimes, haypo, hynek, tarek
priority: normal
severity: normal
stage: needs patch
status: open
title: os.urandom() fails under high load
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list