New submission from Paul Martin <greatestloginnamee...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue40454>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to