[Async-sig] awaiting task is not chaining exception

Chris Jerdonek chris.jerdonek at gmail.com
Sun Nov 12 05:53:19 EST 2017


By the way, since we're already on the subject of asyncio tasks and
(truncated) stack traces, this looks like a good opportunity to ask a
question that's been on my mind for a while:

There's a mysterious note at the end of the documentation of
asyncio.Task's get_stack() method, where it says--

> For reasons beyond our control, only one stack frame is returned for a suspended coroutine.
(https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.get_stack )

What does the "For reasons beyond our control" mean? What is it that
can possibly be beyond the control of Python?

--Chris


On Sat, Nov 11, 2017 at 1:47 AM, Chris Jerdonek
<chris.jerdonek at gmail.com> wrote:
> On Sat, Nov 11, 2017 at 12:39 AM, Nathaniel Smith <njs at pobox.com> wrote:
>> On Fri, Nov 10, 2017 at 9:52 PM, Chris Jerdonek
>> <chris.jerdonek at gmail.com> wrote:
>>> Hi, I recently encountered a situation with asyncio where the stack
>>> trace is getting truncated: an exception isn't getting chained as
>>> expected.
>>>
>>> I was able to reduce it down to the code below.
>>>
>>> The reduced case seems like a pattern that can come up a lot, and I
>>> wasn't able to find an issue on the CPython tracker, so I'm wondering
>>> if I'm doing something wrong or if the behavior is deliberate.
>>
>> I think what you're seeing is collateral damage from some known
>> bugginess in the generator/coroutine .throw() method:
>> https://bugs.python.org/issue29587
>
> Ah, thanks for the great explanation, Nathaniel!
>
> From the original bug report Nathaniel filed above:
>> It's likely that more people will run into this in the future as async/await becomes more widely used. ...
>
> :)
>
> --Chris


More information about the Async-sig mailing list