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.
Created on 2015年03月19日 12:19 by vstinner, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| random.patch | vstinner, 2015年03月19日 13:38 | review | ||
| Messages (3) | |||
|---|---|---|---|
| msg238503 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月19日 12:19 | |
dev_urandom_python() retries read() if it fails with EINTR, but Python signal handlers are not called: PyErr_CheckSignals() is not called. It's important be able to interrupt a function by a signal, especially if it's blocking. We need maybe a new _Py_read() function which would retry on EINTR. The code can be based on posix_read(). For open(), there is already _Py_open() which retries on EINTR (since the changeset ed25e945cdc2, issue #23694). It can be useful for FileIO.read(). dev_urandom_noraise() retries on EINTR without calling PyErr_CheckSignals(). It may be acceptable since this function is only called by _PyRandom_Init() at an early stage of Python initialization. Or maybe EINTR should call Py_FatalError()? On Linux 3.18 (Fedora 21 with kernel 3.18.7-200.fc21.x86_64), reading 1 GB from /dev/urandom or getrandom() returns 0x1ffffff bytes (32 MB). It's not an issue, os.urandom() continues to read until it gets enough data. I tried to interrupt os.urandom() on Python 3.4 (read) and Python 3.5 (getrandom): reading from /dev/urandom using a file descriptor or getrandom() have the same behaviour, none fail with EINTR. I checked syscalls using strace. It looks like getrandom() only fails with EINTR when flags=GRND_RANDOM. So this issue is maybe more theoric. |
|||
| msg238519 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2015年03月19日 13:38 | |
random.patch: fix the issue with the new _Py_read() function added by the issue #23708. |
|||
| msg238574 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年03月19日 22:43 | |
New changeset e57b4d464d1c by Victor Stinner in branch 'default': Issue #23707: On UNIX, os.urandom() now calls the Python signal handler when https://hg.python.org/cpython/rev/e57b4d464d1c |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:14 | admin | set | github: 67895 |
| 2015年03月19日 22:44:11 | vstinner | set | status: open -> closed resolution: fixed |
| 2015年03月19日 22:43:59 | python-dev | set | nosy:
+ python-dev messages: + msg238574 |
| 2015年03月19日 20:20:53 | ned.deily | set | nosy:
+ neologix |
| 2015年03月19日 13:41:20 | vstinner | link | issue23648 dependencies |
| 2015年03月19日 13:38:08 | vstinner | set | files:
+ random.patch keywords: + patch dependencies: + PEP 475: Add _Py_read() and _Py_write() functions messages: + msg238519 |
| 2015年03月19日 12:19:55 | vstinner | create | |