rad  5.1.0
Public Member Functions | List of all members
rad.services.msg.MsgRequestor Class Reference

A message requestor class. More...

Public Member Functions

def __init__ (self, *str endpoint, zmq.asyncio.Context zmq_ctx, asyncio.AbstractEventLoop loop=None, str ident_prefix='anon')
 Create new requestor. More...
 
def __enter__ (self)
 Context manager API implementation. More...
 
def __exit__ (self, *exc)
 Context manager API implementation. More...
 
bool is_closed (self)
 Returns true is the socket accepting requests is closed, false otherwise. More...
 
asyncio.Future send (self, msg)
 Send msg to server. More...
 
asyncio.Future receive (self, msg)
 Receive a reply. More...
 
def close (self)
 Close the connection. More...
 

Detailed Description

A message requestor class.

Note
: The MsgRequestor may also be used as a context manager to automatically close the connection.
Add close or context manager support to automatically clean up
Allow control of identity prefix.

Constructor & Destructor Documentation

◆ __init__()

def rad.services.msg.MsgRequestor.__init__ (   self,
*str  endpoint,
zmq.asyncio.Context  zmq_ctx,
asyncio.AbstractEventLoop  loop = None,
str  ident_prefix = 'anon' 
)

Create new requestor.

Params
endpoint ZMQ endpoint to connect to. zmq_ctx The ZMQ Context to use. loop The asyncio event loop to use. Default is to use the current event loop. ident_prefix Optional identity prefix.

Member Function Documentation

◆ __enter__()

def rad.services.msg.MsgRequestor.__enter__ (   self)

Context manager API implementation.

◆ __exit__()

def rad.services.msg.MsgRequestor.__exit__ (   self,
exc 
)

Context manager API implementation.

◆ close()

def rad.services.msg.MsgRequestor.close (   self)

Close the connection.

◆ is_closed()

bool rad.services.msg.MsgRequestor.is_closed (   self)

Returns true is the socket accepting requests is closed, false otherwise.

◆ receive()

asyncio.Future rad.services.msg.MsgRequestor.receive (   self,
  msg 
)

Receive a reply.

   @note: To abort after a timeout, use `asyncio.wait_for`.
Params
msg Protobuf message instance or type, used to fill/deserialize incoming message.
Returns
Future that resolves to the parsed message.

◆ send()

asyncio.Future rad.services.msg.MsgRequestor.send (   self,
  msg 
)

Send msg to server.

Params
msg Protobuf message.
Returns
Future that resolves when sending is complete.

The documentation for this class was generated from the following file: