Skip to content

Commit

Permalink
Fix BrokenPipeError in SpiceRecordWrapper.close()
Browse files Browse the repository at this point in the history
If spice-record exits for whatever reason, the wrapper will get a
BrokenPipeError when trying to write to the stdin pipe. We simply ignore
this error, as we will later check the exit status in wait().
  • Loading branch information
JonathonReinhart committed Jun 22, 2020
1 parent e525228 commit 30c7524
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spicerecord/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 30c7524

Please sign in to comment.