From f1994dc8da8f30e383508f2c001065e2e2741a91 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 9 Jun 2016 10:39:53 -0700 Subject: Add explicit commentary re #537 in BufferedPipe.set_event --- paramiko/buffered_pipe.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py index e81e9b3d..605f51e9 100644 --- a/paramiko/buffered_pipe.py +++ b/paramiko/buffered_pipe.py @@ -73,6 +73,11 @@ class BufferedPipe (object): self._lock.acquire() try: self._event = event + # Make sure the event starts in `set` state if we appear to already + # be closed; otherwise, if we start in `clear` state & are closed, + # nothing will ever call `.feed` and the event (& OS pipe, if we're + # wrapping one - see `Channel.fileno`) will permanently stay in + # `clear`, causing deadlock if e.g. `select`ed upon. if self._closed or len(self._buffer) > 0: event.set() else: -- cgit v1.2.3