-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Cancel current Job on RejectedExecutionException? #2334
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 because your |
Hmm.. Thanks, I understand now that rejected jobs need to be cancelled (or re-dispatched). |
I finally found what broke in my code and why it was working with 1.3.9. So I'm reporting back here just in case it's useful for someone else. In 1.4.0-M1, rejected runnables are re-dispatched on |
Since
1.4.0-M1
and #2012, a job is cancelled on RejectedExecutionException.This lead to a breaking change in my library, but I understand the reasoning behind. Unless I'm missing something, I looks to me that the cancellation of rejected jobs has side effects which I cannot explain.
I created the snippet below to replicate the issue. I'm creating a ThreadPoolExecutor, and I'm making a Dispatcher out of it with
asCoroutineDispatcher()
. Then, I submit 10 coroutines using that dispatcher, inside a supervisorScope. On my machine, 7 out of 10 coroutines are rejected. However, I looks like the supervisorScope waits forever.The output on my machine:
For the record, I solved my issue by changing the SynchronousQueue for a LinkedBlockingQueue, so I don't have rejections. But I'd like to understand what happens here.
The text was updated successfully, but these errors were encountered: