33from arq import create_pool
44from arq .connections import RedisSettings
55
6+ # Here you can configure the Redis connection.
7+ # The default is to connect to localhost:6379, no password.
8+ REDIS_SETTINGS = RedisSettings ()
9+
610async def download_content (ctx , url ):
711 session : AsyncClient = ctx ['session' ]
812 response = await session .get (url )
@@ -16,17 +20,19 @@ async def shutdown(ctx):
1620 await ctx ['session' ].aclose ()
1721
1822async def main ():
19- redis = await create_pool (RedisSettings () )
23+ redis = await create_pool (REDIS_SETTINGS )
2024 for url in ('https://facebook.com' , 'https://microsoft.com' , 'https://github.com' ):
2125 await redis .enqueue_job ('download_content' , url )
2226
2327# WorkerSettings defines the settings to use when creating the work,
24- # it's used by the arq cli.
25- # For a list of available settings, see https://arq-docs.helpmanual.io/#arq.worker.Worker
28+ # It's used by the arq CLI.
29+ # redis_settings might be ommitted here if using the default settings
30+ # For a list of all available settings, see https://arq-docs.helpmanual.io/#arq.worker.Worker
2631class WorkerSettings :
2732 functions = [download_content ]
2833 on_startup = startup
2934 on_shutdown = shutdown
35+ redis_settings = REDIS_SETTINGS
3036
3137if __name__ == '__main__' :
3238 asyncio .run (main ())
0 commit comments