Skip to content

Latest commit

 

History

History
90 lines (61 loc) · 1.91 KB

zmq.eventloop.future.rst

File metadata and controls

90 lines (61 loc) · 1.91 KB

eventloop.future

Module: eventloop.future

zmq.eventloop.future

zmq.eventloop.future

15.0

As of pyzmq 15, there is a new Socket subclass that returns Futures for recv methods, which can be found at zmq.eventloop.future.Socket. You can create these sockets by instantiating a ~zmq.eventloop.future.Context from the same module. These sockets let you easily use zmq with tornado's coroutines.

tornado:tornado.gen

python

from tornado import gen from zmq.eventloop.future import Context

ctx = Context()

@gen.coroutine def recv_and_process(): sock = ctx.socket(zmq.PULL) sock.bind(url) msg = yield sock.recv_multipart() # waits for msg to be ready reply = yield async_process(msg) yield sock.send_multipart(reply)

Classes

Context

Context class that creates Future-returning sockets. See zmq.Context for more info.

Context

Socket

Socket subclass that returns ~tornado.concurrent.Future s from blocking methods, for use in coroutines and async applications.

zmq.Socket for the inherited API.

Socket

recv

recv_multipart

send

send_multipart

poll

Poller

Poller subclass that returns ~tornado.concurrent.Future s from poll, for use in coroutines and async applications.

zmq.Poller for the inherited API.

Poller

poll