Asynchronous Rabbit RPC

class chu.rpc.RPCRequest(exchange, routing_key, params, timeout=None)[source]

A wrapper object around the exchange, routing_key, and a dictionary of parameters that will be json encoded into the body of the rabbit message.

RPCRequest is hashable and can therefore be used as a key in a dictionary.

class chu.rpc.RPCResponseFuture(cid, timeout=None, io_loop=None)[source]

A convenience object for using AsyncTornadoRPCClient in a non-blocking manner within a Tornado handler. Calls to rpc() will return an instance of RPCResponseFuture. The user may then call RPCResponseFuture.get() in order to retrieve the result of the RPC. Using tornado.gen.Task is recommended for calling get().

get(callback, timeout=None)[source]

Wait for the RPC associated with this RPCResponseFuture to return a result. When the result is received, resolve the task by calling the passed in callback.

Parameters:
  • callback – The callback that will be called with the RPC response upon completion of the RPC. It is recommended that this not be passed in directly, but rather that get() be called as a function passed to tornado.gen.Task.
  • timeout – The amount of time to wait before raising an RPCTimeoutError to indicate that the RPC has timed out. This can be a number or a timedelta object. If it is a number, it will be treated as seconds.
class chu.rpc.AsyncTornadoRPCClient(*args, **kwargs)[source]

Wrap pika.adapters.tornado_connection.TornadoConnection to provide a simple RPC client powered by tornado.gen.engine semantics.

rpc(rpc_request, properties=None, callback=None)[source]

Publish an RPC request. Returns a RPCResponseFuture.

Parameters:rpc_request – An instance of RPCRequest.

Exceptions

exception chu.rpc.RPCTimeoutError[source]

Raised when a call to RPCResponseFuture.wait() times out.

Project Versions

Table Of Contents

Previous topic

Welcome to Chu’s documentation!

Next topic

Chu Connection Details

This Page