Issue with Python multiprocessing pool limit -



Issue with Python multiprocessing pool limit -

i trying write python script launch number of kid processes of finite element simulation code. have been able python spawn of kid processes, problem process pool limit seems ignored. if seek spawn 9 processes set pool = mp.pool(processes=2), 9 processes still start @ once. becomes problem if number of processes exceeds number of lsdyna licenses or number of processors on computer. have read lot multiprocessing package, still first time have tried utilize it. doing wrong here?

import os import multiprocessing mp import subprocess import glob import platform def run_lsdyna(individual_sim_dir, model_name, solver_path): # set lsdyna environment variables os.environ['lstc_license'] = 'network' os.environ['lstc_license_server'] = 'xxx.xx.xx.xx' # phone call cmd prompt lsdyna command line if platform.system() == 'windows': subprocess.call('start "" /d "%s" "%s" i=%s ncpu=1 memory=100m' % (individual_sim_dir, solver_path, model_name), shell=true) # elif platform.system() == 'linux': # elif platform.system() == 'darwin': def unpack(args): # unpacks each set of arguments individuals , sends them run_lsdyna function run_lsdyna(*args) def parallel(sim_dir, procs, model_name, solver_path): # limit number of parallel processes specified value pool = mp.pool(processes=procs) # loop through simulation directories , add together arguments each list args = [] individual_sim_dir in glob.glob(os.path.join(sim_dir, 'channel_*')): args.append((individual_sim_dir, model_name, solver_path)) # send list of arguments unpack function pool.map_async(unpack, args) pool.close() pool.join() if __name__ == "__main__": mp.freeze_support() parallel('c:\users\me\desktop\script_test\lower_leg_sims', 2, 'symmetry_with_boot_1_90_180.k', "c:\lsdyna\program\ls971_s_r5.1.1_winx64_p.exe")

python multiprocessing pool

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -