Taras Voinarovskyi <voyn1...@gmail.com> added the comment:

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())

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35751>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to