Skip to content

Conversation

NewUserHa
Copy link
Contributor

@NewUserHa NewUserHa commented Jan 17, 2025

issue: #128928

it should logging to debug only when loop.debug is true, like other logger.debug() within the asyncio package

# 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__)
Copy link
Contributor

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

Copy link
Contributor Author

@NewUserHa NewUserHa Jan 17, 2025

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

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to reproduce the issue with main branch, please add a test case here

@NewUserHa
Copy link
Contributor Author

I commented "selector class also has a debug log when startup" and forgot to close this issue.
mistake

@NewUserHa NewUserHa closed this Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants