diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-05 12:04:39 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-05 12:04:39 (GMT) |
commit | 5b1261d750793539cf4508a1e76c2f6d20900ac7 (patch) | |
tree | 572bba5ca861d7a3fac3d0ad25570c96aa4f764d /Lib/test/test_subprocess.py | |
parent | d9fc85db7f644c36d8709af49c97bed62451e59a (diff) | |
parent | 2cfb6f3aa086b1f500516372f7179f10c123a777 (diff) | |
download | cpython-5b1261d750793539cf4508a1e76c2f6d20900ac7.zip cpython-5b1261d750793539cf4508a1e76c2f6d20900ac7.tar.gz cpython-5b1261d750793539cf4508a1e76c2f6d20900ac7.tar.bz2 |
(merge 3.2) Issue #12493: subprocess: communicate() handles EINTR
subprocess.Popen.communicate() now also handles EINTR errors if the process has
only one pipe.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 6e31fe7..15d83e7 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -767,6 +767,22 @@ class ProcessTestCase(BaseTestCase): time.sleep(2) p.communicate(b"x" * 2**20) + def test_communicate_eintr(self): + # Issue #12493: communicate() should handle EINTR + def handler(signum, frame): + pass + old_handler = signal.signal(signal.SIGALRM, handler) + self.addCleanup(signal.signal, signal.SIGALRM, old_handler) + + # the process is running for 2 seconds + args = [sys.executable, "-c", 'import time; time.sleep(2)'] + for stream in ('stdout', 'stderr'): + kw = {stream: subprocess.PIPE} + with subprocess.Popen(args, **kw) as process: + signal.alarm(1) + # communicate() will be interrupted by SIGALRM + process.communicate() + # context manager class _SuppressCoreFiles(object): |