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

Class BufferedPipe

source code

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.

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
set_event(self, event)
Set an event on this buffer.
source code
 
feed(self, data)
Feed new data into this pipe.
source code
bool
read_ready(self)
Returns true if data is buffered and ready to be read from this feeder.
source code
str
read(self, nbytes, timeout=None)
Read data from the pipe.
source code
str
empty(self)
Clear out the buffer and return all data that was in it.
source code
 
close(self)
Close this pipe object.
source code
int
__len__(self)
Return the number of bytes buffered.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

set_event(self, event)

source code 

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 (Event) - the event to set/clear

feed(self, data)

source code 

Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done.

Parameters:
  • data (str) - the data to add

read_ready(self)

source code 

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: bool
True if a read call would immediately return at least one byte; False otherwise.

read(self, nbytes, timeout=None)

source code 

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 (int) - maximum number of bytes to read
  • timeout (float) - maximum seconds to wait (or None, the default, to wait forever)
Returns: str
data
Raises:
  • PipeTimeout - if a timeout was specified and no data was ready before that timeout

empty(self)

source code 

Clear out the buffer and return all data that was in it.

Returns: str
any data that was in the buffer prior to clearing it out

close(self)

source code 

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

__len__(self)
(Length operator)

source code 

Return the number of bytes buffered.

Returns: int
number of bytes bufferes