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

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

godlygeek
Copy link
Contributor

@godlygeek godlygeek commented Jun 28, 2024

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.

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 force-pushed the cooperate_with_anyio branch from 73b1a1d to 05b4471 Compare June 30, 2024 04:54
@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]>
@godlygeek godlygeek force-pushed the cooperate_with_anyio branch from 1baa3ba to ac75518 Compare June 30, 2024 05:35
Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pablogsal pablogsal merged commit 1103c12 into bloomberg:main Jul 18, 2024
11 checks passed
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
2 participants