• Sean's avatar
    bpo-24882: Let ThreadPoolExecutor reuse idle threads before creating new thread (#6375) · 904e34d4
    Sean authored
    * Fixes issue 24882
    
    * Add news file entry for change.
    
    * Change test_concurrent_futures.ThreadPoolShutdownTest
    
    Adjust the shutdown test so that, after submitting three jobs
    to the executor, the test checks for less than three threads,
    instead of looking for exactly three threads.
    
    If idle threads are being recycled properly, then we should have
    less than three threads.
    
    * Switched idle count to semaphor, Updated tests
    
    As suggested by reviewer tomMoral, swapped lock-protected counter
    with a semaphore to track the number of unused threads.
    
    Adjusted test_threads_terminate to wait for completiton of the
    previous future before submitting a new one (and checking the
    number of threads used).
    
    Also added a new test to confirm the thread pool can be saturated.
    
    * Updates tests as requested by pitrou.
    
    * Correct minor whitespace error.
    
    * Make test_saturation faster
    904e34d4
2018-04-04-14-54-30.bpo-24882.urybpa.rst 83 Bytes