diff --git a/spicerecord/wrapper.py b/spicerecord/wrapper.py index cb23285..1a982b9 100644 --- a/spicerecord/wrapper.py +++ b/spicerecord/wrapper.py @@ -59,8 +59,12 @@ def __exit__(self, *exc_info): def stop(self): if self.stopped: raise Exception("stop() already called") - self.p.stdin.write(b'Q\n') - self.p.stdin.close() + try: + self.p.stdin.write(b'Q\n') + self.p.stdin.close() + except (BrokenPipeError, IOError): + # The process has already exited + pass self.stopped = True def wait(self):