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

Cooperate with anyio #122

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

Conversation

godlygeek
Copy link
Contributor

anyio allows running async def test functions, but the wrapper installed by Memray to add tracking around the test function breaks anyio's detection.

Work around this by wrapping our wrapper in an async def function, when the wrapped function is a coroutine function.

Closes #119

@godlygeek godlygeek requested a review from pablogsal June 28, 2024 23:29
@godlygeek godlygeek self-assigned this Jun 28, 2024
@godlygeek godlygeek marked this pull request as draft June 28, 2024 23:48
@godlygeek
Copy link
Contributor Author

godlygeek commented Jun 29, 2024

Nope, this doesn't actually work. This gets anyio working, but pytest-memray doesn't wind up working (it just tracks the allocations of creating the coroutine, not of actually executing it).

I'll need to take another swing at this, marking as draft for now...

@godlygeek godlygeek marked this pull request as ready for review June 30, 2024 04:54
@godlygeek
Copy link
Contributor Author

OK, this now actually works, and has a test to prove it.

@godlygeek godlygeek force-pushed the cooperate_with_anyio branch 8 times, most recently from fd24f48 to 1baa3ba Compare June 30, 2024 05:34
`anyio` allows running `async def` test functions, but the wrapper
installed by Memray to add tracking around the test function breaks
`anyio`'s detection.

Work around this by using an `async def` wrapper when the function being
wrapped is a coroutine function.

Signed-off-by: Matt Wozniski <[email protected]>
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.

pytest-memray breaks anyio
1 participant