How would we feel about a method like qsize() on Executors to get the number of requests currently queued for the given executor (but not actively executing yet).
I have a case where an interface takes in an Executor and then manages its lifecycle. I don’t have a way to know how busy that instance (I happen to use ThreadPoolExecutor) is without reaching into the privates of it like here: https://stackoverflow.com/a/68752016
Optimally I’d then use the queue size to emit a metric to know if its falling behind.
Edit: An alternative is to give access to the work queue itself as well.
Would it be possible to use a subclass of ThreadPoolExecutor that provides this visibility? It would be less offensive for a subclass to access _work_queue than something outside the inheritance hierarchy.
I would be reluctant to add Executor.qsize() because an Executor may not have a queue. Putting it on the pool executors would be better, but I still view that as an implementation detail. I understand the value for observability, but I would still consider it a leaky abstraction.