5.2.11. vlcp.event.stream¶
Note
This document is generated from the source file.
Created on 2015/8/14
author: | hubo |
---|
-
class
vlcp.event.stream.
BaseStream
(isunicode=False, encoders=[])¶ Streaming base
-
__init__
(isunicode=False, encoders=[])¶ Constructor
Parameters: - isunicode – if True, the data used in this stream outputs unicode string. Otherwise it outputs bytes.
- encoders – a list of functions enc(data, is_eof) which encodes input data.
-
close
(scheduler, allowwrite=False)¶ Read side close. To close at the write side, use eof=True with write.
Parameters: - scheduler – the scheduler
- allowwrite – do not raise exception on the write side
-
copyTo
(dest, container, buffering=True)¶ Coroutine method to copy content from this stream to another stream.
-
copy_to
(dest, container, buffering=True)¶ Coroutine method to copy content from this stream to another stream.
-
error
(container, ignoreexception=False)¶ Raises error on this stream, so that the receiving end gets an IOError exception.
-
getEncoderList
()¶ Return the encoder list
-
prepareRead
(container=None)¶ A coroutine method to read the next chunk of data.
-
read
(container=None, size=None)¶ Coroutine method to read from the stream and return the data. Raises EOFError when the stream end has been reached; raises IOError if there are other errors.
Parameters: - container – A routine container
- size – maximum read size, or unlimited if is None
-
readline
(container=None, size=None)¶ Coroutine method which reads the next line or until EOF or size exceeds
-
readonce
(size=None)¶ Read from current buffer. If current buffer is empty, returns an empty string. You can use prepareRead to read the next chunk of data.
This is not a coroutine method.
-
write
(data, container, eof=False, ignoreexception=False, buffering=True, split=True)¶ Coroutine method to write data to this stream.
Parameters: - data – data to write
- container – the routine container
- eof – if True, this is the last chunk of this stream. The other end will receive an EOF after reading this chunk.
- ignoreexception – even if the stream is closed on the other side, do not raise exception.
- buffering – enable buffering. The written data may not be sent if buffering = True; if buffering = False, immediately send any data in the buffer together with this chunk.
- split – enable splitting. If this chunk is too large, the stream is allowed to split it into smaller chunks for better balancing.
-
-
class
vlcp.event.stream.
FileStream
(fobj, encoders=[], isunicode=None, size=None, readlimit=65536)¶ A stream from a file-like object. The file-like object must be in blocking mode
-
__init__
(fobj, encoders=[], isunicode=None, size=None, readlimit=65536)¶ Constructor
-
close
(scheduler=None, allowwrite=False)¶ Read side close. To close at the write side, use eof=True with write.
Parameters: - scheduler – the scheduler
- allowwrite – do not raise exception on the write side
-
prepareRead
(container=None)¶ A coroutine method to read the next chunk of data.
-
-
class
vlcp.event.stream.
FileWriter
(fobj)¶ Write to file
-
__init__
(fobj)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
vlcp.event.stream.
MemoryStream
(data, encoders=[], isunicode=None)¶ A stream with readonly data
-
__init__
(data, encoders=[], isunicode=None)¶ Constructor
Parameters: - data – all input data
- encoders – encoder list
- isunicode – Whether this stream outputs unicode. Default to be the same to data. Notice that the encoders may change bytes data to unicode or vice-versa
-
prepareRead
(container=None)¶ A coroutine method to read the next chunk of data.
-
-
class
vlcp.event.stream.
Stream
(isunicode=False, encoders=[], writebufferlimit=4096, splitsize=1048576)¶ Streaming data with events
-
__init__
(isunicode=False, encoders=[], writebufferlimit=4096, splitsize=1048576)¶ Constructor
Parameters: - isunicode – True if this stream outputs unicode; False if this stream outputs bytes
- encoders – a list of functions enc(data, is_eof) which encodes input data.
- writebufferlimit – if buffering=True on write, do not send data until there is more data than this limit
- splitsize – if split=True on write, split chunks larger than this to chunks with this size
-
close
(scheduler, allowwrite=False)¶ Read side close. To close at the write side, use eof=True with write.
Parameters: - scheduler – the scheduler
- allowwrite – do not raise exception on the write side
-
error
(container, ignoreexception=False)¶ Raises error on this stream, so that the receiving end gets an IOError exception.
-
prepareRead
(container=None)¶ A coroutine method to read the next chunk of data.
-
write
(data, container, eof=False, ignoreexception=False, buffering=True, split=True)¶ Coroutine method to write data to this stream.
Parameters: - data – data to write
- container – the routine container
- eof – if True, this is the last chunk of this stream. The other end will receive an EOF after reading this chunk.
- ignoreexception – even if the stream is closed on the other side, do not raise exception.
- buffering – enable buffering. The written data may not be sent if buffering = True; if buffering = False, immediately send any data in the buffer together with this chunk.
- split – enable splitting. If this chunk is too large, the stream is allowed to split it into smaller chunks for better balancing.
-