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
Example of client tracing in the documentation emits a deprecation warning.
Execution without any deprecation warning.
$ python -Wd test.py test.py:7: DeprecationWarning: client.loop property is deprecated trace_config_ctx.start = session.loop.time() test.py:11: DeprecationWarning: client.loop property is deprecated elapsed = session.loop.time() - trace_config_ctx.start Request took 0.2158021649811417
The example is taken from https://docs.aiohttp.org/en/stable/client_advanced.html#client-tracing
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() trace_config.on_request_start.append(on_request_start) trace_config.on_request_end.append(on_request_end) async with aiohttp.ClientSession(trace_configs=[trace_config]) as client: await client.get("http://example.com/some/redirect/") if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(run()) loop.close()
Aiohttp as a client.
$ python -V Python 3.6.8 $ pip freeze | grep aiohttp aiohttp==3.5.4
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?
session.loop
asyncio.get_event_loop()
The text was updated successfully, but these errors were encountered:
The second: use asyncio.get_event_loop() or even better asyncio.get_running_loop()
asyncio.get_running_loop()
Sorry, something went wrong.
Got it, will open a PR fixing the documentation then.
Fixed by #3965
No branches or pull requests
Long story short
Example of client tracing in the documentation emits a deprecation warning.
Expected behaviour
Execution without any deprecation warning.
Actual behaviour
Steps to reproduce
The example is taken from https://docs.aiohttp.org/en/stable/client_advanced.html#client-tracing
Your environment
Aiohttp as a client.
Possible solutions
Should the
session.loop
not emit a deprecation warning? (a.k.a is this a bug?). Or should the example useasyncio.get_event_loop()
instead?The text was updated successfully, but these errors were encountered: