[Python-checkins] cpython: Issue #12363: improve siginterrupt() tests
victor.stinner
python-checkins at python.org
Wed Jun 22 22:16:35 CEST 2011
http://hg.python.org/cpython/rev/aff0a7b0cb12
changeset: 70928:aff0a7b0cb12
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed Jun 22 22:15:51 2011 +0200
summary:
Issue #12363: improve siginterrupt() tests
Add a basic synchronization code between the child and the parent processes:
the child writes "ready" to stdout.
files:
Lib/test/test_signal.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -333,6 +333,9 @@
def handler(signum, frame):
pass
+ print("ready")
+ sys.stdout.flush()
+
signal.signal(signal.SIGALRM, handler)
if interrupt is not None:
signal.siginterrupt(signal.SIGALRM, interrupt)
@@ -353,11 +356,15 @@
""" % (interrupt,)
with spawn_python('-c', code) as process:
try:
+ # wait until the child process is loaded and has started
+ first_line = process.stdout.readline()
+
stdout, stderr = process.communicate(timeout=3.0)
except subprocess.TimeoutExpired:
process.kill()
return False
else:
+ stdout = first_line + stdout
exitcode = process.wait()
if exitcode not in (2, 3):
raise Exception("Child error (exit code %s): %s"
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list