-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
gh-128928: keep consistent of logger.debug of asyncio.BaseProactorEventLoop with others of asyncio #128929
base: main
Are you sure you want to change the base?
Conversation
@@ -638,6 +637,8 @@ def __init__(self, proactor): | |||
if threading.current_thread() is threading.main_thread(): | |||
# wakeup fd can only be installed to a file descriptor from the main thread | |||
signal.set_wakeup_fd(self._csock.fileno()) | |||
if self._debug: | |||
logger.debug('Using proactor: %s', proactor.__class__.__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this reachable? Can you write a test case that shows that it logs when in debug mode?
I worry that to set debug with asyncio.run(coro(), loop_factory=asyncio.ProactorEventLoop, debug=True)
it won't log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had verified that self._debug
does exist in BaseProactorEventLoop
, but with asyncio.run(..., debug=True)
it is still false
while the self._debug
of it only obey from coroutines.py
:
def _is_debug_mode():
# See: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode.
return sys.flags.dev_mode or (not sys.flags.ignore_environment and
bool(os.environ.get('PYTHONASYNCIODEBUG')))
however, this is the same behavior with other classes using self._debug
of base_events.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other EventLoop classes that have a debug log in their constructors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpython/Lib/asyncio/selector_events.py
Lines 52 to 68 in 6c52ada
class BaseSelectorEventLoop(base_events.BaseEventLoop): | |
"""Selector event loop. | |
See events.EventLoop for API specification. | |
""" | |
def __init__(self, selector=None): | |
super().__init__() | |
if selector is None: | |
selector = selectors.DefaultSelector() | |
logger.debug('Using selector: %s', selector.__class__.__name__) | |
self._selector = selector | |
self._make_self_pipe() | |
self._transports = weakref.WeakValueDictionary() | |
seems selector also has a debug log
issue: #128928
it should logging to debug only when loop.debug is true, like other
logger.debug()
within theasyncio
packagelogger.debug
ofasyncio.BaseProactorEventLoop
with others ofasyncio
#128928