Example #1
0
async def main_loop():
    """
    Fetch, forever
    """
    connection = rabbitmq.get_connection()
    connection.declare_queue_consume(rabbitmq.Fetch, NFetchers,
                                     rabbitmq.acking_callback(handle_fetch))
    # Run forever
    await connection._closed_event.wait()
Example #2
0
async def main_loop():
    """
    Run fetchers and renderers, forever.
    """
    async with PgLocker() as pg_locker:

        @rabbitmq.acking_callback_with_requeue
        async def render_callback(*args, **kwargs):
            return await handle_render(pg_locker, *args, **kwargs)

        connection = rabbitmq.get_connection()

        connection.declare_queue_consume(rabbitmq.Render, NRenderers,
                                         render_callback)
        connection.declare_queue_consume(
            rabbitmq.Fetch, NFetchers, rabbitmq.acking_callback(handle_fetch))
        connection.declare_queue_consume(
            rabbitmq.DeletemeUpload, NUploaders,
            rabbitmq.acking_callback(handle_upload_DELETEME))

        # Run forever
        while True:
            await asyncio.sleep(99999)