I am using subprocess in Python to call an external program on WINDOWS. I control the process with ThreadPool so that I can limit it to max 6 processes at the same time, and new process continuously began when one was done.
Codes as below:
### some codes above ### Code of Subprocess Part from multiprocessing.pool import ThreadPool as Pool def FAST_worker(file): p = subprocess.Popen([r'E:/pyworkspace/FAST/FAST_RV_W64.exe', file], cwd = r'E:/pyworkspace/FAST/', shell = True) p.wait() # List of *.in filenames FAST_in_pathname_li = [ '334.in', '893.in', '9527.in', ... '114514.in', '1919810.in', ] # Limit max 6 processes at same time with Pool(processes = 6) as pool: for result in pool.imap_unordered(FAST_worker, FAST_in_pathname_li): pass ### some codes below I got problem when the external program unexpectedly terminated and showed error message pop-up. Though the other 5 processes still kept going, the whole progress will finally get stuck at the "subprocess part" and couldn't go forward anymore. (unless I came to my desk and manually clicked "Shut down the program")
What I want to know is how can I avoid the pop-up and make the whole script process keep going, like bypass the error message or something, rather than manual click, in order to avoid wasting time.