()
| 352 | |
| 353 | |
| 354 | def _shutdown() -> None: |
| 355 | global _process |
| 356 | if _process is not None and _process.poll() is None: |
| 357 | try: |
| 358 | _process.terminate() |
| 359 | _process.wait(timeout=5) |
| 360 | except Exception: |
| 361 | _process.kill() |
| 362 | try: |
| 363 | _process.wait(timeout=5) # reap; a kill without wait leaves a zombie |
| 364 | except Exception: # pragma: no cover - unkillable child |
| 365 | pass |
| 366 | _process = None |
| 367 | |
| 368 | |
| 369 | atexit.register(_shutdown) |