Skip to content

trio_asyncio shielding cancellation causes errors to be silenced. #115

@elektito

Description

@elektito

I was having a hard time figuring out why my program suddenly stopped working without any errors and without keyboard interrupts working. After a lot of digging, I found that there was a simple AttributeError but it wasn't being raised. And it only happened with trio-asyncio running. I managed to come up with this minimal example:

import trio import trio_asyncio async def foo(): async with trio_asyncio.open_loop(): await trio.sleep(0) async def main(): async with trio.open_nursery() as nursery: nursery.start_soon(foo) raise RuntimeError('error!') if __name__ == '__main__': trio.run(main)

Digging further, I found this bit in the _base.py module is to blame:

with trio.CancelScope(shield=True): while not self._stopped.is_set(): await self._main_loop_one()

I'm not familiar with trio_asyncio internals, so I don't know why the shield=True is necessary, but it can clearly cause issues like the one I was experiencing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions