# TODO: Why are we saving this in the app??
    app[APP_CLIENT_RABBIT_DECORATED_HANDLERS_KEY] = [
        partial_rabbit_message_handler
    ]
    await logs_progress_queue.consume(partial_rabbit_message_handler,
                                      exclusive=True,
                                      no_ack=True)

    # instrumentation
    pika_instrumentation_channel = comp_settings.rabbit.channels[
        "instrumentation"]
    instrumentation_exchange = await channel.declare_exchange(
        pika_instrumentation_channel, aio_pika.ExchangeType.FANOUT)
    instrumentation_queue = await channel.declare_queue(
        f"webserver_{id(app)}_instrumentation", exclusive=True)
    await instrumentation_queue.bind(instrumentation_exchange)
    partial_rabbit__instrumentation_handler = rabbit_adapter(app)(
        instrumentation_message_handler)
    app[APP_CLIENT_RABBIT_DECORATED_HANDLERS_KEY].extend(
        [partial_rabbit__instrumentation_handler])
    await instrumentation_queue.consume(
        partial_rabbit__instrumentation_handler, exclusive=True, no_ack=False)


@retry(**RabbitMQRetryPolicyUponInitialization().kwargs)
async def wait_till_rabbitmq_responsive(url: str) -> bool:
    """Check if something responds to ``url`` """
    connection = await aio_pika.connect(url)
    await connection.close()
    return True
Beispiel #2
0
async def _wait_till_rabbit_responsive(url: str) -> None:
    async for attempt in AsyncRetrying(
            **RabbitMQRetryPolicyUponInitialization().kwargs):
        with attempt:
            connection = await aio_pika.connect(url, timeout=1.0)
            await connection.close()