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

AttributeError: 'async_generator_asend' object has no attribute '__name__' #2340

Closed
hemslo opened this issue Mar 10, 2024 · 0 comments · Fixed by #2521 or #2541
Closed

AttributeError: 'async_generator_asend' object has no attribute '__name__' #2340

hemslo opened this issue Mar 10, 2024 · 0 comments · Fixed by #2521 or #2541
Labels
bug Something isn't working

Comments

@hemslo
Copy link

hemslo commented Mar 10, 2024

Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.

opentelemetry-instrumentation-asyncio==0.44b0, error when anext used in asyncio.create_task, because async_generator_asend object has no __name__.

Python 3.11.7, tested on both macos and in linux container.

Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.

# anext.py
import asyncio


async def main():
    async def async_gen():
        for i in range(2):
            yield i

    async_gen_instance = async_gen()
    a = anext(async_gen_instance)
    await asyncio.create_task(a)


if __name__ == "__main__":
    asyncio.run(main())
opentelemetry-instrument python3 anext.py

What is the expected behavior?
No error

What is the actual behavior?

AttributeError: 'async_generator_asend' object has no attribute '__name__'. Did you mean: '__ne__'?

Additional context

The exception is thrown from trace_coroutine, anext return async_generator_asend object, it can pass asyncio.iscoroutine check as True, but it doesn't have __name__. Expect either skip this kind of coroutine or construct name differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment