Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Asyncio exception handling breaks convention by logging callback parameter values #112997

Closed
Labels
@CendioZeijlon

Description

@CendioZeijlon

Bug report

Bug description:

My understanding is that Python usually does not attempt to log or show parameter and variable values when errors occur. It seems uncharacteristic that asyncio does so, e.g. when it handles uncaught exceptions.

This type of logging can also occur when asyncio reports on tasks with too slow execution times, but then only in debug mode.

When not in debug mode, parameter values are logged for uncaught exceptions, but not for slow execution times. I don't see why these two cases behave differently. If you think that this logging is necessary, perhaps it can be limited to debug mode only?

Input:

importasyncioimportfunctoolsloop=asyncio.new_event_loop()asyncio.set_event_loop(loop)deftest_callback(a,b,c,*,x,y,z):raiseRuntimeError('Some uncaught error')loop.call_soon(functools.partial(test_callback,        {'key':'value'},        ['value'],        ('value',),x= {'key':'value'},y= ['value'],z= ('value',)    ))loop.call_soon(loop.stop)res=''try:loop.run_forever()finally:loop.close()

Output:

Exception in callback test_callback({'key': 'value'}, ['value'], ('value',), x={'key': 'value'}, y=['value'], z=('value',))() at /home/aleze/Documents/scenario.py:7handle: <Handle test_callback({'key': 'value'}, ['value'], ('value',), x={'key': 'value'}, y=['value'], z=('value',))() at /home/aleze/Documents/scenario.py:7>Traceback (most recent call last):  File "/usr/lib64/python3.11/asyncio/events.py", line 80, in _run    self._context.run(self._callback, *self._args)  File "/home/aleze/Documents/scenario.py", line 8, in test_callback    raise RuntimeError('Some uncaught error')RuntimeError: Some uncaught error

Extra:

The function that actually creates the output isformat_helpers._format_args_and_kwargs().

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp