to close the TODO in _ThreadPoolExecutor._adjust_thread_count
with self._available_thread._value -- that semaphore counts the number of idle threads, but the semaphore counts from max_workers, so if there are 3 / 5 workers running then the semaphore value reads 2 while there are no idle threads, so we gotta also subtract out potential threads
another badass upgrade here would be for it to autoscale down if workload goes down ( if idle_threads > queue size for extended periods ) .. that might automatically happen
to close the TODO in _ThreadPoolExecutor._adjust_thread_count
with
self._available_thread._value
-- that semaphore counts the number of idle threads, but the semaphore counts from max_workers, so if there are 3 / 5 workers running then the semaphore value reads 2 while there are no idle threads, so we gotta also subtract out potential threadspotentially_idle_threads = self._available_thread.value
unused_threads = self.max_workers - num_threads
idle_threads = potentially_idle_threads - unused_threads
then
threads_needed = idle_threads < self._work_queue.qsize()
another badass upgrade here would be for it to autoscale down if workload goes down ( if idle_threads > queue size for extended periods ) .. that might automatically happen