summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--paramiko/buffered_pipe.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py
index eb33734b..ab89675f 100644
--- a/paramiko/buffered_pipe.py
+++ b/paramiko/buffered_pipe.py
@@ -154,6 +154,23 @@ class BufferedPipe (object):
return out
+ def empty(self):
+ """
+ Clear out the buffer and return all data that was in it.
+
+ @return: any data that was in the buffer prior to clearing it out
+ @rtype: str
+ """
+ self._lock.acquire()
+ try:
+ out = self._buffer.tostring()
+ del self._buffer[:]
+ if (self._event is not None) and not self._closed:
+ self._event.clear()
+ return out
+ finally:
+ self._lock.release()
+
def close(self):
"""
Close this pipe object. Future calls to L{read} after the buffer