Context manager killing the subprocess if a Python exception is raised.
(proc)
| 25 | |
| 26 | @contextmanager |
| 27 | def kill_on_error(proc): |
| 28 | """Context manager killing the subprocess if a Python exception is raised.""" |
| 29 | with proc: |
| 30 | try: |
| 31 | yield proc |
| 32 | except: |
| 33 | proc.kill() |
| 34 | raise |
| 35 | |
| 36 | |
| 37 | class MockSocketFile: |
no test coverage detected
searching dependent graphs…