Skip to content

Aiohttp server Background task loop deprecated #3526

Closed
@gcetusic

Description

Long story short

In the docs there is an explanation on how to create a Background task (in this case, a Redis listener)

https://docs.aiohttp.org/en/stable/web_advanced.html

I want to create a background task to listen for Postgres notifications.

Expected behaviour

In the docs, the example is app.loop.create_task(listen_to_redis(app)) and this should be the official working example or a different one if this one is deprecated.

Actual behaviour

When running the code, a warning occurs:

gateway.py:39: DeprecationWarning: loop property is deprecated app['listener'] = app.loop.create_task(listen(app)) Traceback (most recent call last): File "gateway.py", line 117, in <module> web.run_app(app) File "/home/goc/.virtualenvs/doorway/lib/python3.7/site-packages/aiohttp/web.py", line 210, in run_app reuse_port=reuse_port)) File "/usr/local/lib/python3.7/asyncio/base_events.py", line 573, in run_until_complete return future.result() concurrent.futures._base.CancelledError

Steps to reproduce

https://github.com/gcetusic/doorway/blob/master/gateway.py#L39

Your environment

Aiohttp server instance (version 3.5.3), Ubuntu 18.04

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions