From 33e4760531c503943e75da52137cf0f7067ff1df Mon Sep 17 00:00:00 2001 From: Ramon Giovane <40267373+RamonGiovane@users.noreply.github.com> Date: Mon, 1 Apr 2024 11:44:37 -0300 Subject: [PATCH] Improve RedisSettings explanation in main_demo.py (#422) Co-authored-by: Samuel Colvin --- docs/examples/main_demo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/examples/main_demo.py b/docs/examples/main_demo.py index b6c57315..7ccb2401 100644 --- a/docs/examples/main_demo.py +++ b/docs/examples/main_demo.py @@ -3,6 +3,10 @@ from arq import create_pool from arq.connections import RedisSettings +# Here you can configure the Redis connection. +# The default is to connect to localhost:6379, no password. +REDIS_SETTINGS = RedisSettings() + async def download_content(ctx, url): session: AsyncClient = ctx['session'] response = await session.get(url) @@ -16,17 +20,19 @@ async def shutdown(ctx): await ctx['session'].aclose() async def main(): - redis = await create_pool(RedisSettings()) + redis = await create_pool(REDIS_SETTINGS) for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com'): await redis.enqueue_job('download_content', url) # WorkerSettings defines the settings to use when creating the work, -# it's used by the arq cli. -# For a list of available settings, see https://arq-docs.helpmanual.io/#arq.worker.Worker +# It's used by the arq CLI. +# redis_settings might be ommitted here if using the default settings +# For a list of all available settings, see https://arq-docs.helpmanual.io/#arq.worker.Worker class WorkerSettings: functions = [download_content] on_startup = startup on_shutdown = shutdown + redis_settings = REDIS_SETTINGS if __name__ == '__main__': asyncio.run(main())