supervisorScope
The supervisorScope function also behaves a lot like coroutineScope: it creates a CoroutineScope that inherits from the outer scope and calls the specified suspend block in it. The difference is that it overrides the context’s Job with Supervisor-Job, so it is not cancelled when a child raises an exception.
supervisorScope is mainly used in functions that start multiple independent tasks. - Kotlin Coroutines Deep Dive
Highlight
- Does NOT cancel when child raises an exception.
- Does NOT cancel children when child raises an exception.
- Waits for ALL children, even failing ones, even after some have failed and threw.
- Collects ALL exceptions from co-routines.
Notes
Children
Backlinks