[New-bugs-announce] [issue40454] DEBUG kw to asyncio.run overrides DEBUG mode set elsewhere

Paul Martin report at bugs.python.org
Thu Apr 30 16:06:09 EDT 2020


New submission from Paul Martin <greatestloginnameever at gmail.com>:

According to the docs:

"
There are several ways to enable asyncio debug mode.

Setting the PYTHONASYNCIODEBUG environment variable to 1.
Using the -X dev Python command line option.
Passing debug=True to asyncio.run().
Calling loop.set_debug().
"

My understanding of this would be that any of the above methods can be used to enable debug mode. However if asyncio.run is used then whatever value for DEBUG is passed to asyncio.run (or False by default) overrides DEBUG mode being set elsewhere. So, when asyncio.run is used, the only way to enable DEBUG mode is to pass DEBUG=True to asyncio.run. The other methods won't work. 

One solution might be to change this line in asyncio/runners.py:

loop.set_debug(debug)

To

loop.set_debug(debug or coroutines._DEBUG)

So asyncio.run won't disable debug mode if it's already been set elsewhere

----------
components: asyncio
messages: 367779
nosy: asvetlov, primal, yselivanov
priority: normal
severity: normal
status: open
title: DEBUG kw to asyncio.run overrides DEBUG mode set elsewhere
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40454>
_______________________________________


More information about the New-bugs-announce mailing list