def target_fn(): import purerpc server = purerpc.Server(port=0) server.add_service(service) socket = server._create_socket_and_listen() yield socket.getsockname()[1] anyio.run(server._run_async_server, socket)
def target_fn(): server = purerpc.Server(port=0) server.add_service(service) socket = server._create_socket_and_listen() queue.put(socket.getsockname()[1]) queue.close() queue.join_thread() curio.run(server._run_async_server, socket)
def target_fn(): import purerpc server = purerpc.Server(port=0) server.add_service(service) socket = server._create_socket_and_listen() yield socket.getsockname()[1] async def sleep_10_seconds_then_die(): await anyio.sleep(20) raise ValueError async def main(): async with anyio.create_task_group() as tg: await tg.spawn(server._run_async_server, socket) await tg.spawn(sleep_10_seconds_then_die) # import cProfile anyio.run(server._run_async_server, socket)
def main(): server = purerpc.Server(50055, num_processes=1) server.add_service(Servicer().service) server.serve()