Package paramiko :: Module buffered_pipe :: Class BufferedPipe
[show private | hide private]
[frames | no frames]

Type BufferedPipe

object --+
         |
        BufferedPipe


A buffer that obeys normal read (with timeout) & close semantics for a file or socket, but is fed data from another thread. This is used by Channel.
Method Summary
  __init__(self)
int __len__(self)
Return the number of bytes buffered.
  close(self)
Close this pipe object.
str empty(self)
Clear out the buffer and return all data that was in it.
  feed(self, data)
Feed new data into this pipe.
str read(self, nbytes, timeout)
Read data from the pipe.
bool read_ready(self)
Returns true if data is buffered and ready to be read from this feeder.
  set_event(self, event)
Set an event on this buffer.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__len__(self)
(Length operator)

Return the number of bytes buffered.
Returns:
number of bytes bufferes
           (type=int)

close(self)

Close this pipe object. Future calls to read after the buffer has been emptied will return immediately with an empty string.

empty(self)

Clear out the buffer and return all data that was in it.
Returns:
any data that was in the buffer prior to clearing it out
           (type=str)

feed(self, data)

Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done.
Parameters:
data - the data to add
           (type=str)

read(self, nbytes, timeout=None)

Read data from the pipe. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by nbytes. If a string of length zero is returned, the pipe has been closed.

The optional timeout argument can be a nonnegative float expressing seconds, or None for no timeout. If a float is given, a PipeTimeout will be raised if the timeout period value has elapsed before any data arrives.
Parameters:
nbytes - maximum number of bytes to read
           (type=int)
timeout - maximum seconds to wait (or None, the default, to wait forever)
           (type=float)
Returns:
data
           (type=str)
Raises:
PipeTimeout - if a timeout was specified and no data was ready before that timeout

read_ready(self)

Returns true if data is buffered and ready to be read from this feeder. A False result does not mean that the feeder has closed; it means you may need to wait before more data arrives.
Returns:
True if a read call would immediately return at least one byte; False otherwise.
           (type=bool)

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.
Parameters:
event - the event to set/clear
           (type=Event)

Generated by Epydoc 2.1 on Wed Aug 16 14:35:04 2006 http://epydoc.sf.net