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
deadlock with asyncio+contextmanager+ExitStack #69965
Comments
The following hangs at 100% CPU on Python 3.5, though not on Python 3.4:
Here's an example script that does all of this and repros the hang: https://gist.github.com/oconnor663/483db2820bb5f877c9ed |
Interestingly, it doesn't hang when you raise a different error. There's some new code dealing with the RuntimeError coming out of a generator if it raises StopIteration (instead of returning) introduced by issue bpo-22906. Yury, it looks like you introduced that? (The diff is this: changeset: 95932:36a8d935c322 |
Trying to reproduce without contextstack. |
Here's a minimal test to reproduce: import reprlib
def main():
if 0:
yield
raise RuntimeError
m = main()
try:
m.send(None)
except RuntimeError as ex:
ex.__context__ = ex
reprlib.repr(ex)
Looks like it's a bug in reprlib. It's not related to PEP 492/479. It's also reproducible in Python 3.4 and 3.3. Nick, ExitStack does this (indirectly) 'ex.__context__ = ex' thing -- I think that's a bug of contextlib. |
Created another issue for the reprlib bug: bpo-25781. It appears we don't even need a generator: import reprlib
Closing this one with "not a bug". |
It's not even a reprlib bug: try: |
Thanks for chasing this down. Yury, can you suggest a workaround? |
I'm not sure how to workaround this :( Hopefully we can fix this in 3.5.1. |
FWIW the bug was identified in bpo-25782. I've drafted a patch to fix it, please review. |
The question is whether we should raise an exception or not: ex.__context__ = ex |
Another issue for contextlib: http://bugs.python.org/issue25786 |
Yury, can you help me understand why |
hasattr uses getattr under the hood. getattr raises an AttributeError, and that triggers PyErr_SetError, which has an infinite "while" loop. Instead of "hasattr" you can use anything that raises an error. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: