Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create():
server = yield from aiozmq.rpc.serve_rpc(
MyHandler(),
bind='tcp://127.0.0.1:{}'.format(port),
loop=self.loop)
client = yield from aiozmq.rpc.connect_rpc(
connect='tcp://127.0.0.1:{}'.format(port),
loop=self.loop)
return client, server
def go():
server = yield from aiozmq.rpc.serve_rpc(
handlers_dict, bind='tcp://*:*')
server_addr = next(iter(server.transport.bindings()))
client = yield from aiozmq.rpc.connect_rpc(
connect=server_addr)
ret = yield from client.call.a()
assert 'a' == ret
ret = yield from client.call.subnamespace.b()
assert 'b' == ret
server.close()
client.close()
async def RPCContext(addr, timeout=10):
preserved_exceptions = (
NotFoundError,
ParametersError,
asyncio.TimeoutError,
asyncio.CancelledError,
asyncio.InvalidStateError,
)
server = None
try:
server = await aiozmq.rpc.connect_rpc(
connect=addr, error_table={
'concurrent.futures._base.TimeoutError': asyncio.TimeoutError,
})
server.transport.setsockopt(zmq.LINGER, 50)
with _timeout(timeout):
yield server
except Exception:
exc_type, exc, tb = sys.exc_info()
if issubclass(exc_type, GenericError):
e = AgentError(exc.args[0], exc.args[1])
raise e.with_traceback(tb)
elif issubclass(exc_type, preserved_exceptions):
raise
else:
e = AgentError(exc_type, exc.args)
raise e.with_traceback(tb)
def go():
server = yield from aiozmq.rpc.serve_rpc(
ServerHandler(), bind='tcp://*:*')
server_addr = list(server.transport.bindings())[0]
client = yield from aiozmq.rpc.connect_rpc(
connect=server_addr,
error_table=error_table)
try:
yield from client.call.remote('value')
except CustomError as exc:
exc.val == 'value'
server.close()
client.close()
def replay_client(port):
"""Create an RPC client to request raw/event data and send unblock requests.
:param port: server port.
"""
client = yield from rpc.connect_rpc(
connect='tcp://127.0.0.1:{}'.format(port),
translation_table=translation_table
)
return client
def go():
server = yield from aiozmq.rpc.serve_rpc(
ServerHandler(), bind='tcp://*:*')
server_addr = next(iter(server.transport.bindings()))
client = yield from aiozmq.rpc.connect_rpc(
connect=server_addr)
ret = yield from client.call.remote_func(1, 2)
assert 3 == ret
server.close()
client.close()
def go():
server = yield from aiozmq.rpc.serve_rpc(
ServerHandler(), bind='tcp://*:*')
server_addr = next(iter(server.transport.bindings()))
client = yield from aiozmq.rpc.connect_rpc(
connect=server_addr)
try:
yield from client.call.unknown_function()
except aiozmq.rpc.NotFoundError as exc:
print("client.rpc.unknown_function(): {}".format(exc))
try:
yield from client.call.remote_func(bad_arg=1)
except aiozmq.rpc.ParametersError as exc:
print("client.rpc.remote_func(bad_arg=1): {}".format(exc))
try:
yield from client.call.remote_func(1)
except aiozmq.rpc.ParametersError as exc:
print("client.rpc.remote_func(1): {}".format(exc))
def go():
server = yield from aiozmq.rpc.serve_rpc(
ServerHandler(), bind='tcp://*:*',
translation_table=translation_table)
server_addr = next(iter(server.transport.bindings()))
client = yield from aiozmq.rpc.connect_rpc(
connect=server_addr,
translation_table=translation_table)
ret = yield from client.call.remote(Point(1, 2))
assert ret == Point(1, 2)
server.close()
client.close()