-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aiohttp server Background task loop deprecated #3526
Comments
Just drop |
What would be the proper way to create the background task? Something like this?
|
Yes. |
what should i use instead of this is my case: app = web.Application(loop=loop, middlewares=get_middlewares())
app.on_startup.append(load_plugins)
# ...
async def load_plugins(app):
app.mongo = Mongo.create()
app.mongo.initialize(app.loop)
app.redis = await get_cache(loop=app.loop) In this case is better to wait for an update of |
@rafa-acioly I believe the idea is to still use the loop if a third party library requires it but it's instead of referencing app.loop, just use what you get from get_running_loop(). |
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
The text was updated successfully, but these errors were encountered: