diff options
author | Robey Pointer <robey@lag.net> | 2006-04-11 15:47:33 -0700 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2006-04-11 15:47:33 -0700 |
commit | b7a615d02a9b96f85b10edbb60cc08d395cbfd28 (patch) | |
tree | 0f88255b96f741e41e085b432dece02a081ccdae | |
parent | 1df0e7e629d4a97f1b6010490b5d225712541c33 (diff) |
[project @ robey@lag.net-20060411224733-0361ad3758aee64d]
add a way to set the event to trigger, and fix a typo
-rw-r--r-- | paramiko/buffered_pipe.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py index 8e1aacd0..eb33734b 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() |