Executor queue size

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.

Open to thoughts/suggestions. Thanks.

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.

It’s possible though still odd since technically _work_queue could change in a future version of python as it isn’t documented.

I guess a wrapper class could be written around the ThreadPoolExecutor and use a semaphore as a counter to know how many are in progress vs waiting.

Still: It would be nice if it was more directly accessible than via a private or fully wrapping the object.