Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/async_kernel/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ async def wait(
break
return done, pending

def create_pending_group(self, *, shield: bool = False):
def create_pending_group(self, *, shield: bool = False, mode: Literal[0, 1, 2] = 0) -> PendingGroup:
"""
Create a new [PendingGroup][async_kernel.pending.PendingGroup] instance.

Expand All @@ -1124,6 +1124,10 @@ def create_pending_group(self, *, shield: bool = False):

Args:
shield: Shield the pending group from external cancellation.
mode: The mode.
- 0: Ignore cancellation of pending.
- 1: Cancel if any pending is cancelled - raise PendingCancelled on exit.
- 2: Cancel if any pending is cancelled - exit quietly.

Usage:

Expand All @@ -1133,4 +1137,4 @@ def create_pending_group(self, *, shield: bool = False):
...
```
"""
return PendingGroup(shield=shield)
return PendingGroup(shield=shield, mode=mode)
Loading