Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
peer = PeerInvoker(
connect=ZeroMQAddress(addr),
transport=ZeroMQRPCTransport,
serializer=msgpack.packb,
deserializer=msgpack.unpackb,
)
await peer.__aenter__()
agent_peers[addr] = peer
try:
with _timeout(timeout):
okey_token = peer.call.order_key.set('')
try:
yield peer
finally:
peer.call.order_key.reset(okey_token)
except RPCUserError as orig_exc:
raise AgentError(orig_exc.name, orig_exc.args)
except Exception:
raise
peer = agent_peers.get(addr, None)
if peer is None:
log.debug('Estabilshing connection to tcp://{}:16001', addr)
peer = PeerInvoker(
connect=ZeroMQAddress(f'tcp://{addr}:16001'),
transport=ZeroMQRPCTransport,
serializer=msgpack.packb,
deserializer=msgpack.unpackb,
)
await peer.__aenter__()
agent_peers[addr] = peer
try:
with _timeout(timeout):
peer.call.order_key.set(order_key)
yield peer
except RPCUserError as orig_exc:
raise AgentError(orig_exc.name, orig_exc.args)
except Exception:
raise