From 1ce734903269745133bcfe7e48fad55fe2a02931 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Fri, 19 Jun 2020 14:36:36 -0400 Subject: [PATCH] test: Add a sleep to deflake a test Not sure why this has recently started happening in some environments, but killing a process too soon causes the wrong exit status in some python builds on macOS. --- tornado/test/process_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index 4f2b1e63a..1f2992024 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -4,6 +4,7 @@ import os import signal import subprocess import sys +import time import unittest from tornado.httpclient import HTTPClient, HTTPError @@ -224,6 +225,14 @@ class SubprocessTest(AsyncTestCase): ) self.addCleanup(subproc.stdout.close) subproc.set_exit_callback(self.stop) + + # For unclear reasons, killing a process too soon after + # creating it can result in an exit status corresponding to + # SIGKILL instead of the actual signal involved. This has been + # observed on macOS 10.15 with Python 3.8 installed via brew, + # but not with the system-installed Python 3.7. + time.sleep(0.1) + os.kill(subproc.pid, signal.SIGTERM) try: ret = self.wait(timeout=1.0) -- 2.47.3