maybe try this while threading.activeCount() < MAX_THREADS: # .... instead of while threading < MAX_THREADS: