Ejemplo n.º 1
0
async def clean_up_endpoint(endpoint: TrinityEventBusEndpoint) -> None:
    """
    Used when the event bus is the only thing to exit. This should probably
    be changed when lahja is more sync-friendly.
    """
    loop = asyncio.get_event_loop()
    async with exit_signal(loop):
        endpoint.stop()
Ejemplo n.º 2
0
async def handle_networking_exit(service: BaseService,
                                 plugin_manager: PluginManager,
                                 endpoint: TrinityEventBusEndpoint) -> None:

    async with exit_signal_with_service(service):
        await plugin_manager.shutdown()
        endpoint.stop()
        # Retrieve and shutdown the global executor that was created at startup
        ensure_global_asyncio_executor().shutdown(wait=True)
Ejemplo n.º 3
0
async def event_bus(event_loop):
    endpoint = TrinityEventBusEndpoint()
    # Tests run concurrently, therefore we need unique IPC paths
    ipc_path = Path(f"networking-{uuid.uuid4()}.ipc")
    networking_connection_config = ConnectionConfig(
        name=NETWORKING_EVENTBUS_ENDPOINT, path=ipc_path)
    await endpoint.start_serving(networking_connection_config, event_loop)
    await endpoint.connect_to_endpoints(networking_connection_config)
    try:
        yield endpoint
    finally:
        endpoint.stop()
Ejemplo n.º 4
0
async def exit_with_endpoint_and_services(
        endpoint: TrinityEventBusEndpoint,
        *services_to_exit: BaseService) -> None:
    async with exit_signal_with_services(*services_to_exit):
        endpoint.stop()
Ejemplo n.º 5
0
async def exit_with_service_and_endpoint(service_to_exit: BaseService,
                                         endpoint: TrinityEventBusEndpoint) -> None:
    async with exit_signal_with_service(service_to_exit):
        endpoint.stop()