
On Fri, Jan 3, 2020 at 3:28 PM Miguel Ángel Prosper < miguelangel.prosper@gmail.com> wrote:
gets one item from the queue, runs it, and then checks if the executor is being shut down.
That's exactly what I thought at first, but just after that the continue statement prevents that check, so all futures always get processed. Only when the sentinel is reached, which it's placed at the end, it actually does the check.
Keen eye!
perhaps we can add some functionality where leftover work items are explicitly cancelled? I think that would satisfy the OP's requirement.
Yes that would be perfect, that way we could have a controlled but fast exit for certain scenarios, such as the ones listed in the first post.
From what I examined the procedure would be very similar to the one followed when a initializer fails, both implementations clear all pending futures when it happens. On ThreadPoolExecutor specifically, just calling a modified version of _initializer_failed at the time discussed would seem to be sufficient, changing the call Future.set_exception to Future.cancel.
OK, since the current behavior of shutdown() is "disallow submitting new futures and wait for all currently queued futures to be processed", we definitely need a new flag. It looks like you have a good handle on the code -- do you want to submit a PR to GitHub to add such a parameter? -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>