MP Stuff
import os
import sys
import multiprocessing
from subprocess import call
# ------------------------------------------------------------------------------
def init_process():
processName = multiprocessing.current_process().name
if len(processName) > 0:
pass
# ------------------------------------------------------------------------------
def do_processing(oneFullPathPyFile):
call(["python", oneFullPathPyFile])
# ------------------------------------------------------------------------------
pool_size = multiprocessing.cpu_count() * 2
pool = multiprocessing.Pool(processes=pool_size, initializer=init_process,)
for one_arg in sys.argv[1:]:
dir_path = os.path.abspath(one_arg)
for thisDir, subDirs, filesHere in os.walk(dir_path):
fullFilePaths = []
for oneFile in filesHere:
fullPath = os.path.join(thisDir, oneFile)
fullFilePaths.append(fullPath)
pool_outputs = pool.map(do_processing, fullFilePaths)
pool.close() # no more tasks
pool.join() # wrap up current tasks