コード例 #1
0
def test_endpoint_broadcast_from_client_to_server(ipc_base_path, runner):
    server_config = ConnectionConfig.from_name("server", base_path=ipc_base_path)

    server = d.driver(d.serve_endpoint(server_config), d.wait_for(Event))

    client = d.driver(
        d.run_endpoint("client"),
        d.connect_to_endpoints(server_config),
        d.wait_any_then_broadcast(Event()),
    )

    runner(server, client)
コード例 #2
0
async def test_endpoint_driver(ipc_base_path):
    server_config = ConnectionConfig.from_name("server",
                                               base_path=ipc_base_path)

    server_done = asyncio.Event()

    server = driver(
        serve_endpoint(server_config),
        wait_for(Event, on_event=lambda endpoint, event: server_done.set()),
    )

    client = driver(
        run_endpoint("client"),
        connect_to_endpoints(server_config),
        wait_until_any_endpoint_subscribed_to(Event),
        broadcast(Event()),
    )

    asyncio.ensure_future(server(AsyncioEngine()))
    asyncio.ensure_future(client(AsyncioEngine()))

    await asyncio.wait_for(server_done.wait(), timeout=0.1)