-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
TrioInternalError yielding out of an async generator that has opened a nursery #1443
Comments
Sorry for the delay in responding to this. It looks like you're trying to yield out of an async generator that has opened a nursery. This isn't supported; see #264 and #638 for more discussion on why. It's unlikely to ever be supported, but we do want to make it blow up less horribly than what you experienced. The full fix probably requires a change to the Python interpreter, but it's likely that we can detect certain common cases and give a more informative error. (We already do this for cancel scopes, which have basically the same set of problems.) I'm going to leave this issue open in case someone has the cycles to figure out why this particular case gave a nasty error instead of a useful one. If you're able to give more information about the crashes you're running into, or an even semi-reliable independent reproducer, that would help, but I understand if you can't. |
@oremanj Thanks for explanation and the linked issues. I now understand what to fix when rewriting my code. I have not seen this error recurred since the day I reported. Base on the information you provided, I suspect that the error is due to the nursery's cancel scope inside an async generator is cancelled outside the async generator.1 I try to produce a minimal reproducer out of my understanding. The best thing I can get produce two different tracebacks randomly (function names are retained for comparison): import trio
async def _loop():
async def heartbeat_s():
await trio.sleep_forever()
async def heartbeat_n_receive():
async with trio.open_nursery() as nursery:
nursery.start_soon(heartbeat_s)
with trio.move_on_after(0):
yield
rq, _ = trio.open_memory_channel(0)
async with trio.open_nursery() as _:
async for x in heartbeat_n_receive():
await rq.send(x)
trio.run(_loop) (Note that these were produced with Python 3.8.1, Trio 0.13.0) Traceback 1 (seen in original post, with additional gc errors):
Traceback 2:
Hope that these help for future testing! I will follow the updates in the related issues. 1 In particular, |
Python 3.8.1
Trio 0.13.0
What I have seen:
Relavent code:
This has never happened,
but I have seen this twice today. Other probably relevant information: the file system and/or network is slow at that time, I am seeing lots ofIt happens more frequently later. I'm now suspecting that if some hidden weak point in my code get overwhelmed.heartbeat response timeout
in my log (see the relevant code above).Sorry for dumping lots of shallow information. I am not sure what else should I report, and please rename the title to a more precise name.
The text was updated successfully, but these errors were encountered: