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

Support functools.partial functions in AsyncioInstrumentor.trace_to_thread #2911

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

Conversation

ecarrara
Copy link

Change trace_to_thread method to retrieve the function name from the func attribute of the functools.partial instance.

partial objects are like function objects in that they are callable, weak referenceable, and can have attributes. There are some important differences. For instance, the name and function.doc attributes are not created automatically. Also, partial objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look-up.
https://docs.python.org/3.12/library/functools.html#partial-objects

Fixes #2910

…hread

Change `trace_to_thread` method to retrieve the function name from the
`func` attribute of the `functools.partial` instance.

> partial objects are like function objects in that they are callable, weak
> referenceable, and can have attributes. There are some important differences.
> For instance, the __name__ and function.__doc__ attributes are not created
> automatically. Also, partial objects defined in classes behave like static
> methods and do not transform into bound methods during instance attribute
> look-up.
>
> Reference: https://docs.python.org/3.12/library/functools.html#partial-objects
Copy link

linux-foundation-easycla bot commented Oct 17, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'functools.partial' object has no attribute '__name__' in AsyncioInstrumentor.trace_to_thread
2 participants