diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-22 20:15:51 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-22 20:15:51 (GMT) |
commit | 4527365ee4241246e437031b23dc62eb10b589e4 (patch) | |
tree | 534f1857fae8fd81bddda2217a773acc00e229ae /Lib | |
parent | c0a9f75fbae5b70fe98887d36a32229165f7d60a (diff) | |
download | cpython-4527365ee4241246e437031b23dc62eb10b589e4.zip cpython-4527365ee4241246e437031b23dc62eb10b589e4.tar.gz cpython-4527365ee4241246e437031b23dc62eb10b589e4.tar.bz2 |
Issue #12363: improve siginterrupt() tests
Add a basic synchronization code between the child and the parent processes:
the child writes "ready" to stdout.
Diffstat (limited to 'Lib')
-rw-r--r-- | 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 index e613f5b..8a5a408 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -333,6 +333,9 @@ class SiginterruptTest(unittest.TestCase): 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 @@ class SiginterruptTest(unittest.TestCase): """ % (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" |