From b7a615d02a9b96f85b10edbb60cc08d395cbfd28 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 11 Apr 2006 15:47:33 -0700 Subject: [PATCH] [project @ robey@lag.net-20060411224733-0361ad3758aee64d] add a way to set the event to trigger, and fix a typo --- paramiko/buffered_pipe.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py index 8e1aacd..eb33734 100644 --- a/paramiko/buffered_pipe.py +++ b/paramiko/buffered_pipe.py @@ -48,6 +48,21 @@ class BufferedPipe (object): self._buffer = array.array('B') self._closed = False + def set_event(self, event): + """ + Set an event on this buffer. When data is ready to be read (or the + buffer has been closed), the event will be set. When no data is + ready, the event will be cleared. + + @param event: the event to set/clear + @type event: Event + """ + self._event = event + if len(self._buffer) > 0: + event.set() + else: + event.clear() + def feed(self, data): """ Feed new data into this pipe. This method is assumed to be called @@ -133,7 +148,7 @@ class BufferedPipe (object): self._event.clear() else: out = self._buffer[:nbytes].tostring() - del self.in_buffer[:nbytes] + del self._buffer[:nbytes] finally: self._lock.release()