This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tvoinarovskyi
Recipients asvetlov, tvoinarovskyi, yselivanov
Date 2019-01-16.14:25:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547648748.64.0.794019129938.issue35751@roundup.psfhosted.org>
In-reply-to
Content
So yes, the `clear_frames` function will force a running generator to close. See https://github.com/python/cpython/blob/3.7/Objects/frameobject.c#L566, it explicitly does a Finalize. Would that be the desired behaviour for assertRaises is not clear. I find it strange that catching an exception is closing my running coroutine.

The reproduce example can be lowered to something like::

    import asyncio


    async def background(error_future):
        try:
            raise ValueError
        except Exception as exc:
            error_future.set_exception(exc)

        await asyncio.sleep(1)


    async def main():
        loop = asyncio.get_event_loop()
        error_future = loop.create_future()
        task = asyncio.create_task(background(error_future))

        await asyncio.wait([error_future])
        exc = error_future.exception()
        import traceback
        traceback.clear_frames(exc.__traceback__)

        # Will block forever, as task will never be waken up
        await task


    if __name__ == "__main__":
        asyncio.run(main())
History
Date User Action Args
2019-01-16 14:25:49tvoinarovskyisetrecipients: + tvoinarovskyi, asvetlov, yselivanov
2019-01-16 14:25:48tvoinarovskyisetmessageid: <1547648748.64.0.794019129938.issue35751@roundup.psfhosted.org>
2019-01-16 14:25:48tvoinarovskyilinkissue35751 messages
2019-01-16 14:25:48tvoinarovskyicreate