Skip to content

Commit

Permalink
Close pipe's write fd before the read one
Browse files Browse the repository at this point in the history
This should theoretically get rid of one possible exception ("Broken
pipe") happening in `Bus._transition()` due to a race condition.

Ref #16
  • Loading branch information
webknjaz committed Mar 20, 2021
1 parent 835e173 commit 282cf75
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion magicbus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 282cf75

Please sign in to comment.