Package qbuf :: Module socket_support :: Class LineReceiver

Class LineReceiver

source code

    object --+    
             |    
_SocketWrapper --+
                 |
                LineReceiver

A socket wrapper for line buffering.

Iterating over a LineBuffer will yield each line available in the buffer. If the socket is closed, iterating over a LineBuffer will raise a SocketClosedError.

Instance Methods
 
__init__(self, sock, buffer_size=4096, delimiter='\r\n', auto_pump=True)
Wrap a socket for easier line buffering of incoming data.
source code
 
__iter__(self) source code
 
readline(self)
Read a line out of the buffer.
source code

Inherited from _SocketWrapper: close, fileno, pump_buffer, send, sendall

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, sock, buffer_size=4096, delimiter='\r\n', auto_pump=True)
(Constructor)

source code 

Wrap a socket for easier line buffering of incoming data.

The buffer_size parameter indicates how much should be read from the socket at a time. If the auto_pump parameter is True, iterating over the LineReceiver and calling readline will automatically try to read new socket data into the buffer first.

Overrides: object.__init__

readline(self)

source code 

Read a line out of the buffer.

If the socket is closed, this function returns an empty string. If no line is available, socket.error is raised with an errno of EAGAIN. Otherwise, return the next line available in the buffer.