Public Member Functions | |
def | __init__ |
def | close |
def | closed |
def | connect |
def | read_bytes |
def | read_until |
def | read_until_close |
def | read_until_regex |
def | reading |
def | set_close_callback |
def | write |
def | writing |
Public Attributes | |
error | |
io_loop | |
max_buffer_size | |
read_chunk_size | |
socket | |
Private Member Functions | |
def | _add_io_state |
def | _check_closed |
def | _consume |
def | _handle_connect |
def | _handle_events |
def | _handle_read |
def | _handle_write |
def | _maybe_add_error_listener |
def | _maybe_run_close_callback |
def | _read_from_buffer |
def | _read_from_socket |
def | _read_to_buffer |
def | _run_callback |
def | _set_read_callback |
def | _try_inline_read |
Private Attributes | |
_close_callback | |
_connect_callback | |
_connecting | |
_pending_callbacks | |
_read_buffer | |
_read_buffer_size | |
_read_bytes | |
_read_callback | |
_read_delimiter | |
_read_regex | |
_read_until_close | |
_state | |
_streaming_callback | |
_write_buffer | |
_write_buffer_frozen | |
_write_callback |
Definition at line 39 of file iostream.py.
def tornado.iostream.IOStream.__init__ | ( | self, | |
socket, | |||
io_loop = None , |
|||
max_buffer_size = 104857600 , |
|||
read_chunk_size = 4096 |
|||
) |
Definition at line 84 of file iostream.py.
def tornado.iostream.IOStream._add_io_state | ( | self, | |
state | |||
) | [private] |
Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler. Implementation notes: Reads and writes have a fast path and a slow path. The fast path reads synchronously from socket buffers, while the slow path uses `_add_io_state` to schedule an IOLoop callback. Note that in both cases, the callback is run asynchronously with `_run_callback`. To detect closed connections, we must have called `_add_io_state` at some point, but we want to delay this as much as possible so we don't have to set an `IOLoop.ERROR` listener that will be overwritten by the next slow-path operation. As long as there are callbacks scheduled for fast-path ops, those callbacks may do more reads. If a sequence of fast-path ops do not end in a slow-path op, (e.g. for an @asynchronous long-poll request), we must add the error handler. This is done in `_run_callback` and `write` (since the write callback is optional so we can have a fast-path write with no `_run_callback`)
Definition at line 573 of file iostream.py.
def tornado.iostream.IOStream._check_closed | ( | self | ) | [private] |
Definition at line 562 of file iostream.py.
def tornado.iostream.IOStream._consume | ( | self, | |
loc | |||
) | [private] |
Definition at line 555 of file iostream.py.
def tornado.iostream.IOStream._handle_connect | ( | self | ) | [private] |
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 498 of file iostream.py.
def tornado.iostream.IOStream._handle_events | ( | self, | |
fd, | |||
events | |||
) | [private] |
Definition at line 258 of file iostream.py.
def tornado.iostream.IOStream._handle_read | ( | self | ) | [private] |
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 334 of file iostream.py.
def tornado.iostream.IOStream._handle_write | ( | self | ) | [private] |
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 516 of file iostream.py.
def tornado.iostream.IOStream._maybe_add_error_listener | ( | self | ) | [private] |
Definition at line 566 of file iostream.py.
def tornado.iostream.IOStream._maybe_run_close_callback | ( | self | ) | [private] |
Definition at line 237 of file iostream.py.
def tornado.iostream.IOStream._read_from_buffer | ( | self | ) | [private] |
Attempts to complete the currently-pending read from the buffer. Returns True if the read was completed.
Definition at line 438 of file iostream.py.
def tornado.iostream.IOStream._read_from_socket | ( | self | ) | [private] |
Attempts to read from the socket. Returns the data read or None if there is nothing to read. May be overridden in subclasses.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 395 of file iostream.py.
def tornado.iostream.IOStream._read_to_buffer | ( | self | ) | [private] |
Reads from the socket and appends the result to the read buffer. Returns the number of bytes read. Returns 0 if there is nothing to read (i.e. the read returns EWOULDBLOCK or equivalent). On error closes the socket and raises an exception.
Definition at line 413 of file iostream.py.
def tornado.iostream.IOStream._run_callback | ( | self, | |
callback, | |||
args | |||
) | [private] |
Definition at line 300 of file iostream.py.
def tornado.iostream.IOStream._set_read_callback | ( | self, | |
callback | |||
) | [private] |
Definition at line 367 of file iostream.py.
def tornado.iostream.IOStream._try_inline_read | ( | self | ) | [private] |
Attempt to complete the current read operation from buffered data. If the read can be completed without blocking, schedules the read callback on the next IOLoop iteration; otherwise starts listening for reads on the socket.
Definition at line 371 of file iostream.py.
def tornado.iostream.IOStream.close | ( | self | ) |
Close this stream.
Definition at line 219 of file iostream.py.
def tornado.iostream.IOStream.closed | ( | self | ) |
Returns true if the stream has been closed.
Definition at line 254 of file iostream.py.
def tornado.iostream.IOStream.connect | ( | self, | |
address, | |||
callback = None |
|||
) |
Connects the socket to a remote address without blocking. May only be called if the socket passed to the constructor was not previously connected. The address parameter is in the same format as for socket.connect, i.e. a (host, port) tuple. If callback is specified, it will be called when the connection is completed. Note that it is safe to call IOStream.write while the connection is pending, in which case the data will be written as soon as the connection is ready. Calling IOStream read methods before the socket is connected works on some platforms but is non-portable.
Definition at line 109 of file iostream.py.
def tornado.iostream.IOStream.read_bytes | ( | self, | |
num_bytes, | |||
callback, | |||
streaming_callback = None |
|||
) |
Call callback when we read the given number of bytes. If a ``streaming_callback`` is given, it will be called with chunks of data as they become available, and the argument to the final ``callback`` will be empty.
Definition at line 155 of file iostream.py.
def tornado.iostream.IOStream.read_until | ( | self, | |
delimiter, | |||
callback | |||
) |
Call callback when we read the given delimiter.
Definition at line 149 of file iostream.py.
def tornado.iostream.IOStream.read_until_close | ( | self, | |
callback, | |||
streaming_callback = None |
|||
) |
Reads all data from the socket until it is closed. If a ``streaming_callback`` is given, it will be called with chunks of data as they become available, and the argument to the final ``callback`` will be empty. Subject to ``max_buffer_size`` limit from `IOStream` constructor if a ``streaming_callback`` is not used.
Definition at line 168 of file iostream.py.
def tornado.iostream.IOStream.read_until_regex | ( | self, | |
regex, | |||
callback | |||
) |
Call callback when we read the given regex pattern.
Definition at line 143 of file iostream.py.
def tornado.iostream.IOStream.reading | ( | self | ) |
Returns true if we are currently reading from the stream.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 246 of file iostream.py.
def tornado.iostream.IOStream.set_close_callback | ( | self, | |
callback | |||
) |
Call the given callback when the stream is closed.
Definition at line 215 of file iostream.py.
def tornado.iostream.IOStream.write | ( | self, | |
data, | |||
callback = None |
|||
) |
Write the given data to this stream. If callback is given, we call it when all of the buffered write data has been successfully written to the stream. If there was previously buffered write data and an old write callback, that callback is simply overwritten with this new callback.
Definition at line 187 of file iostream.py.
def tornado.iostream.IOStream.writing | ( | self | ) |
Returns true if we are currently writing to the stream.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 250 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
tornado::iostream.IOStream::_connecting [private] |
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
tornado::iostream.IOStream::_read_buffer [private] |
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
tornado::iostream.IOStream::_read_bytes [private] |
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
tornado::iostream.IOStream::_read_regex [private] |
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
tornado::iostream.IOStream::_state [private] |
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Definition at line 84 of file iostream.py.
Reimplemented in tornado.iostream.SSLIOStream.
Definition at line 84 of file iostream.py.