Skip to content
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

Client tracing example emits deprecation warning #3964

jcugat opened this issue Aug 7, 2019 · 3 comments


Copy link

commented Aug 7, 2019

Long story short

Example of client tracing in the documentation emits a deprecation warning.

Expected behaviour

Execution without any deprecation warning.

Actual behaviour

$ python -Wd DeprecationWarning: client.loop property is deprecated
  trace_config_ctx.start = session.loop.time() DeprecationWarning: client.loop property is deprecated
  elapsed = session.loop.time() - trace_config_ctx.start
Request took 0.2158021649811417

Steps to reproduce

The example is taken from

import asyncio

import aiohttp

async def on_request_start(session, trace_config_ctx, params):
    trace_config_ctx.start = session.loop.time()

async def on_request_end(session, trace_config_ctx, params):
    elapsed = session.loop.time() - trace_config_ctx.start
    print("Request took {}".format(elapsed))

async def run():
    trace_config = aiohttp.TraceConfig()
    async with aiohttp.ClientSession(trace_configs=[trace_config]) as client:
        await client.get("")

if __name__ == "__main__":
    loop = asyncio.get_event_loop()

Your environment

Aiohttp as a client.

$ python -V
Python 3.6.8
$ pip freeze | grep aiohttp

Possible solutions

Should the session.loop not emit a deprecation warning? (a.k.a is this a bug?). Or should the example use asyncio.get_event_loop() instead?


This comment has been minimized.

Copy link

commented Aug 7, 2019

The second: use asyncio.get_event_loop() or even better asyncio.get_running_loop()


This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

Got it, will open a PR fixing the documentation then.


This comment has been minimized.

Copy link

commented Aug 8, 2019

Fixed by #3965

@asvetlov asvetlov closed this Aug 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.