I have a python script that process a list of time consuming tasks via calling subprocess, with ThreadPoolExecutor + max_worker to execute a small number of tasks in parallel. I want to be able to let the script know that i want the script to only finish the ongoing tasks, but stop scheduling new tasks not started yet. Initially i want it to be handled via a keyboard hot key (something like ctrl+p, but cant be ctrl+c given it will kill the subprocesses immediately) I tried pynput and keyboard, but neither of them can get my key presses in WSL terminal. Is there any other good solution here? Some approaches I want to avoid: using input func given it is blocking create an additional file and let the script to check if the file exist / content in the file Continue reading...