import tempfile import subprocess import pathlib from concurrent.futures import ThreadPoolExecutor def run(msg): with tempfile.TemporaryDirectory() as tmp_dir: tmp_path = pathlib.Path(tmp_dir) subprocess.run(["true"]) if tmp_path.exists(): print(msg, "Ok") else: print(msg, "!"*80) if __name__ == "__main__": print("with ThreadPoolExecutor() as executor") with ThreadPoolExecutor() as executor: executor.map(run, ["with"]*128) print("executor = ThreadPoolExecutor()") executor = ThreadPoolExecutor() executor.map(run, [None]*128)