➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 vstinner
收信人 christian.heimes, hynek, tarek, vstinner
日期 2013-08-16.15:30:57
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1376667057.94.0.579949604711.issue18756@psf.upfronthosting.co.za>
In-reply-to
内容
> 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.
历史
日期 用户 动作 参数
2013-08-16 15:30:57vstinner修改recipients: + vstinner, christian.heimes, tarek, hynek
2013-08-16 15:30:57vstinner修改messageid: <1376667057.94.0.579949604711.issue18756@psf.upfronthosting.co.za>
2013-08-16 15:30:57vstinner链接issue18756 messages
2013-08-16 15:30:57vstinner创建