Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

@@ -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__)
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

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.

2 participants