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.
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.