Class BatchedSend
Batch messages in batches on a stream
Declaration
class BatchedSend
source linkDocumentation
This takes an IOStream and an interval (in ms) and ensures that we send no
more than one message every interval milliseconds. We send lists of
messages.
Batching several messages at once helps performance when sending
a myriad of tiny messages.
Examples
>>> stream = yield connect(address)
>>> bstream = BatchedSend(interval='10 ms')
>>> bstream.start(stream)
>>> bstream.send('Hello,')
>>> bstream.send('world!')
On the other side, the recipient will get a message like the following::
['Hello,', 'world!']
Methods
▷ def __init__(self, interval, loop=None, serializers=None) ▶ def close(self, timeout=None) @gen.coroutine Flush existing messages and then close comm
@gen.coroutine
def close(
self,
timeout=None,
)
If set, raises `tornado.util.TimeoutError` after a timeout.
▶ def send(self, msg) Schedule a message for sending to the other side
This completes quickly and synchronously
Reexports