-
-
Notifications
You must be signed in to change notification settings - Fork 378
Description
Here's a strange crash, discovered by @florimondmanca in encode/httpx#214:
import trio
async def gen():
yield "hi"
trio.run(gen().__anext__)Results in:
Traceback (most recent call last):
File "/tmp/asdf.py", line 6, in <module>
trio.run(gen().__anext__)
File "/home/njs/.user-python3.7/lib/python3.7/site-packages/trio/_core/_run.py", line 1769, in run
run_impl(runner, async_fn, args)
File "/home/njs/.user-python3.7/lib/python3.7/site-packages/trio/_core/_run.py", line 1918, in run_impl
runner.task_exited(task, final_outcome)
File "/home/njs/.user-python3.7/lib/python3.7/site-packages/trio/_core/_run.py", line 1404, in task_exited
raise TrioInternalError
trio.TrioInternalError
Poking around, I see that init has set self.main_task_outcome before exiting:
(Pdb) p self.main_task_outcome
Error(AttributeError("'async_generator_asend' object has no attribute 'cr_frame'"))
So this is another variant of #550.
This is a pretty weird thing to do, so I guess this issue isn't super urgent, but two todo items:
-
The error message is really bad... there are several measures in place here to try to make the error come out, and they all failed. The run loop tries to reveal exceptions from
init, butinitexited successfully. It did this after settingself.main_task_exited... but even thoughspawn_implfailed, it didn't fail until after adding the new task toself.tasks, sorunfreaked out instead of re-raisingself.main_task_exited. I guess we should move theself.tasksassignment down even further inspawn_impl? -
Also, this probably shouldn't crash! And Support Cython-based async functions #550 has another set of reasons to support it.