Skip to content

Nurseries do not reraise cancellation if parent cancel scope is cancelled #3291

Open
@A5rocks

Description

@A5rocks

This might be intended? Here's the reproduction:

>>> import trio
>>> async def main():
...     with trio.CancelScope() as cs:
...         try:
...             async with trio.open_nursery() as nursery:
...                 nursery.cancel_scope.cancel()
...                 cs.cancel()
...                 await trio.lowlevel.checkpoint()
...         except trio.Cancelled as e:
...             print("cancelled:")
...             print(repr(e.__context__))
...
>>> trio.run(main)
>>> async def main():
...     with trio.CancelScope() as cs:
...         try:
...             with trio.CancelScope() as cs2:
...                 cs2.cancel()
...                 cs.cancel()
...                 await trio.lowlevel.checkpoint()
...         except trio.Cancelled as e:
...             print("cancelled:")
...             print(repr(e.__context__))
...
>>> trio.run(main)
cancelled:
None

@goodboy brought this up on Gitter.

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