Skip to content
This repository was archived by the owner on Mar 29, 2026. It is now read-only.
This repository was archived by the owner on Mar 29, 2026. It is now read-only.

Asyncio instrumentation - object has no attribute __qualname__ #115

@nectarindev

Description

@nectarindev

Some internal coroutines in the cpython implementation may not have the __qualname__ attribute.

Therefore, errors may occur on this line:

For example, this code

import autodynatrace
import asyncio

async def generator():
    yield 42

async def main():
    gen = generator()
    await anext(gen)
    await gen.athrow(ValueError())

asyncio.run(main())

gives the following error:

<coroutine object BaseEventLoop.shutdown_asyncgens at 0x7cee66f50ae0>
<async_generator_athrow object at 0x7cee66f66980>
an error occurred during closing of asynchronous generator <async_generator object generator at 0x7cee678977f0>
asyncgen: <async_generator object generator at 0x7cee678977f0>
Traceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nectarin/dev/autodynatrace/.venv/lib/python3.12/site-packages/autodynatrace/wrappers/asyncio/wrapper.py", line 34, in dynatrace_run_until_complete
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/nectarin/dev/autodynatrace/main.py", line 10, in main
    await gen.athrow(ValueError())
  File "/home/nectarin/dev/autodynatrace/main.py", line 5, in generator
    yield 42
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nectarin/dev/autodynatrace/.venv/lib/python3.12/site-packages/autodynatrace/wrappers/asyncio/wrapper.py", line 23, in trace_coro
    name = coro.__qualname__
           ^^^^^^^^^^^^^^^^^
AttributeError: 'async_generator_athrow' object has no attribute '__qualname__'
<coroutine object BaseEventLoop.shutdown_default_executor at 0x7cee67773340>
Traceback (most recent call last):
  File "/home/nectarin/dev/autodynatrace/main.py", line 12, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nectarin/dev/autodynatrace/.venv/lib/python3.12/site-packages/autodynatrace/wrappers/asyncio/wrapper.py", line 34, in dynatrace_run_until_complete
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/nectarin/dev/autodynatrace/main.py", line 10, in main
    await gen.athrow(ValueError())
  File "/home/nectarin/dev/autodynatrace/main.py", line 5, in generator
    yield 42
ValueError

Expected behavior

Clean traceback without autodynatrace errors:

Traceback (most recent call last):
  File "/home/nectarin/dev/autodynatrace/main.py", line 12, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/nectarin/dev/autodynatrace/main.py", line 10, in main
    await gen.athrow(ValueError())
  File "/home/nectarin/dev/autodynatrace/main.py", line 5, in generator
    yield 42
ValueError

Additional context
Ubuntu 24.04
Python 3.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions