(self)
| 207 | self.assertEqual(subproc.returncode, ret) |
| 208 | |
| 209 | def test_sigchild_signal(self): |
| 210 | Subprocess.initialize() |
| 211 | self.addCleanup(Subprocess.uninitialize) |
| 212 | subproc = Subprocess( |
| 213 | [sys.executable, "-c", "import time; time.sleep(30)"], |
| 214 | stdout=Subprocess.STREAM, |
| 215 | ) |
| 216 | self.addCleanup(subproc.stdout.close) |
| 217 | subproc.set_exit_callback(self.stop) |
| 218 | |
| 219 | # For unclear reasons, killing a process too soon after |
| 220 | # creating it can result in an exit status corresponding to |
| 221 | # SIGKILL instead of the actual signal involved. This has been |
| 222 | # observed on macOS 10.15 with Python 3.8 installed via brew, |
| 223 | # but not with the system-installed Python 3.7. |
| 224 | time.sleep(0.1) |
| 225 | |
| 226 | os.kill(subproc.pid, signal.SIGTERM) |
| 227 | try: |
| 228 | ret = self.wait() |
| 229 | except AssertionError: |
| 230 | # We failed to get the termination signal. This test is |
| 231 | # occasionally flaky on pypy, so try to get a little more |
| 232 | # information: did the process close its stdout |
| 233 | # (indicating that the problem is in the parent process's |
| 234 | # signal handling) or did the child process somehow fail |
| 235 | # to terminate? |
| 236 | fut = subproc.stdout.read_until_close() |
| 237 | fut.add_done_callback(lambda f: self.stop()) # type: ignore |
| 238 | try: |
| 239 | self.wait() |
| 240 | except AssertionError: |
| 241 | raise AssertionError("subprocess failed to terminate") |
| 242 | else: |
| 243 | raise AssertionError( |
| 244 | "subprocess closed stdout but failed to " "get termination signal" |
| 245 | ) |
| 246 | self.assertEqual(subproc.returncode, ret) |
| 247 | self.assertEqual(ret, -signal.SIGTERM) |
| 248 | |
| 249 | @gen_test |
| 250 | def test_wait_for_exit_raise(self): |
nothing calls this directly
no test coverage detected