-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Disallow Job
passed as context to withContext
/launch
/async
#3670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is continuation of #814 (comment) |
Let's consider correct use cases, and declare the rest incorrect.
Can be detected by checking the parent handle. It is essentially the same as 1 and should be handled as such.
The above example will hang the current coroutine because a child is attached, but never completed.
This does not make much sense, (To be continued) |
Nice write-up, thanks! |
The tricky thing is migration here. I don't think we can just make it into an error one day. It has to start with a warning. Ideally, a compiler-time warning, but it is not obvious how to provide one. A runtime warning can be considered, but it is a tough sell for a core library. |
A deprecated error level overload that takes a It can start with a warning level too, without enforcing it at runtime until after a version raises the warning (for |
What do we have now?
It's possible to pass
Job
as part of context to the mentioned functions:What should be instead?
Error should be logged when a
Job
is detected in the added context.Why?
All above cases "replace" the context
Job
and attach the scopeJob
to the passedJob()
as a child.This might be unexpected at best, and plain dangerous because it breaks parent-child relation.
The text was updated successfully, but these errors were encountered: