[…] If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException. […]
Why would the await function resume with a CancellationException if the job completes while await is waiting?
j
Joffrey
02/03/2022, 5:55 PM
I don't believe the current coroutine could complete normally if it is suspended on
await
anyway. But it's indeed a bit confusing that they mention "completed" as an option here 🤔
n
Nick Allen
02/03/2022, 7:57 PM
You can switch to a
CompletableJob
using
withContext
and complete it while
await
is called.
Edit: had a play link here, but mistyped it so it was inaccurate.