diff --git a/magicbus/base.py b/magicbus/base.py index fdda16b8..2a2a68f8 100644 --- a/magicbus/base.py +++ b/magicbus/base.py @@ -352,8 +352,10 @@ def _wait(): self.publish(channel) finally: self._state_transition_pipes.discard(pipe) - os.close(read_fd) + # NOTE: Closing the write file descriptor first + # NOTE: to prevent "Broken pipe" in `self._transition()`. os.close(write_fd) + os.close(read_fd) # From http://psyco.sourceforge.net/psycoguide/bugs.html: # "The compiled machine code does not include the regular polling