-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Test suite explodes if a nursery's __aexit__ doesn't get called #82
Comments
related to python-trio/trio#1045 |
This might be the same issue as python-trio/trio#882 -- if you look inside the |
It's definitely true that nursery objects expect you to implement the context manager protocol properly, and that this is surprisingly complicated to do by hand. So some kind of pyrotechnics are expected here. Is the request that this give a better error message, or... what would have helped you? |
I was mostly trying to be a good citizen, I knew I was doing something wrong but the error message requested I open an issue and since I'm new to the library it wasn't clear to me so I erred on the side of caution. Recommendations from someone else had me re-architect so that I could use a |
Might be fixed by python-trio/trio#1061, and if not then I think the remaining parts are covered by python-trio/trio#1056. So closing this. |
What is wrong
I am manually managing the lifecycle of a nursery in a class that exposes it's own async context manager API (this might be a bad idea but I think it's extraneous to the error I've hit).
I had a bug in my
__aenter__
implementation which resulted in the method erroring out after having already started the nursery. This results in theNursery.__aexit__
never being called which I believe is why the error happens.Here's a minimal example that demonstrates the problem:
If I run this directly from the shell using
$ python test_example.py
the output is clearly from my exception:However, run through pytest this is what happens:
Not clear what needs to be done to fix this or whether it is something that should be fixed.
The text was updated successfully, but these errors were encountered: