[issue19850] asyncio: limit EINTR occurrences with SA_RESTART

Charles-François Natali report at bugs.python.org
Sun Dec 1 13:09:15 CET 2013


New submission from Charles-François Natali:

asyncio makes heavy use of SIGCHLD for subprocesses.
A consequence of this if that a lot of syscalls can fail with EINTR (see e.g. issue #18885).

The attached patch uses SA_RESTART (through signal.siginterrupt()) to limit EINTR occurrences, e.g. :
"""
$ ./python -c "import os; from signal import *; signal(SIGALRM, lambda *args: None); alarm(1); os.read(0, 1)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
InterruptedError: [Errno 4] Interrupted system call
"""

With siginterrupt(False):
"""
$ ./python -c "import os; from signal import *; signal(SIGALRM, lambda *args: None); siginterrupt(SIGALRM, False); alarm(1); os.read(0, 1)"
[manual interruption]
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
KeyboardInterrupt
"""

It doesn't come with test because it's hard to come up with a syscall that's guaranteed to be restarted on al OS (and also because I'm having a hard time with all those mock-based asyncio tests ;-), but at least it doesn't break the test suite :-)

See https://groups.google.com/d/topic/python-tulip/9T2_tGWe0Sc/discussion for more background.

----------
components: Library (Lib)
files: asyncio_sa_restart.diff
keywords: patch
messages: 204915
nosy: gvanrossum, neologix
priority: normal
severity: normal
stage: patch review
status: open
title: asyncio: limit EINTR occurrences with SA_RESTART
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file32923/asyncio_sa_restart.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19850>
_______________________________________


More information about the Python-bugs-list mailing list