Context manager killing the subprocess if a Python exception is raised.
(proc)
| 34 | |
| 35 | @contextlib.contextmanager |
| 36 | def kill_on_error(proc): |
| 37 | """Context manager killing the subprocess if a Python exception is raised.""" |
| 38 | with proc: |
| 39 | try: |
| 40 | yield proc |
| 41 | except: |
| 42 | proc.kill() |
| 43 | raise |
| 44 | |
| 45 | |
| 46 | @unittest.skipUnless(hasattr(signal, "setitimer"), "requires setitimer()") |
no test coverage detected
searching dependent graphs…