db_run.py 504 B

123456789101112131415161718
  1. from concurrent.futures import ThreadPoolExecutor
  2. from pathlib import Path
  3. import subprocess
  4. def task(name):
  5. return subprocess.Popen(f'C:\\Windows\\System32\\cmd.exe /C "{name}"', stdout=subprocess.DEVNULL).wait()
  6. def run(base_dir):
  7. files = [str(f) for f in Path(base_dir).glob('*.bat') if not f.name.startswith('_')]
  8. with ThreadPoolExecutor(max_workers=5) as executor:
  9. executor.map(task, files)
  10. if __name__ == '__main__':
  11. run('C:\\GlobalCube\\System\\OPTIMA\\SQL\\batch')