Skip to content

Commit 33e4760

Browse files
Improve RedisSettings explanation in main_demo.py (#422)
Co-authored-by: Samuel Colvin <[email protected]>
1 parent 9731f54 commit 33e4760

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docs/examples/main_demo.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from arq import create_pool
44
from 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+
610
async 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

1822
async 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
2631
class WorkerSettings:
2732
functions = [download_content]
2833
on_startup = startup
2934
on_shutdown = shutdown
35+
redis_settings = REDIS_SETTINGS
3036

3137
if __name__ == '__main__':
3238
asyncio.run(main())

0 commit comments

Comments
 (0)