|
rad
3.0.0
|
Public Member Functions | |
| def | __init__ (self, *str endpoint, zmq.asyncio.Context zmq_ctx, msg_handler, asyncio.AbstractEventLoop loop) |
| bool | is_closed (self) |
| Returns true if the socket is closed, true otherwise. More... | |
| def | start (self) |
| Start reading from socket. More... | |
| def | send (self, bytes identity, bytes msg_name, bytes msg) |
Send msg with name msg_name to identity. More... | |
| def | stop (self) |
| Unbinds socket and shuts down all related tasks to this Replier. More... | |
| def rad.services.msg.ZmqMsgReplier.__init__ | ( | self, | |
| *str | endpoint, | ||
| zmq.asyncio.Context | zmq_ctx, | ||
| msg_handler, | |||
| asyncio.AbstractEventLoop | loop | ||
| ) |
| bool rad.services.msg.ZmqMsgReplier.is_closed | ( | self | ) |
Returns true if the socket is closed, true otherwise.
| def rad.services.msg.ZmqMsgReplier.send | ( | self, | |
| bytes | identity, | ||
| bytes | msg_name, | ||
| bytes | msg | ||
| ) |
Send msg with name msg_name to identity.
RuntimeError if socket is closed.
| def rad.services.msg.ZmqMsgReplier.start | ( | self | ) |
Start reading from socket.
@todo: Return future instead?
| def rad.services.msg.ZmqMsgReplier.stop | ( | self | ) |
Unbinds socket and shuts down all related tasks to this Replier.
The ZmqMsgReplier is essentially dead after this.
Examples
>> import zmq >> import asyncio >> loop = asyncio.new_event_loop() >> def handler(identity, msg_name, msg): .. pass >> replier = ZmqMsgReplier(msg_handler=handler, .. endpoint='inproc://foobar', zmq_ctx=zmq.asyncio.Context(), loop=loop) >> fut = replier.stop() >> loop.run_until_complete(asyncio.wait_for(fut, 2)) >> loop.close()