-
Notifications
You must be signed in to change notification settings - Fork 0
/
sightline_analysis_subproc_manager.py
47 lines (34 loc) · 1.37 KB
/
sightline_analysis_subproc_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#################################################
# Manage processes running sightline_analysis.py,
# as it likes to read datasets wrong & segfault
#################################################
import yt
yt.enable_parallelism(suppress_logging=True)
import glob
import subprocess
import os
from mpi4py import MPI
from sightline_analysis import process_dataset
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
def launch_subprocess(filename):
proc = subprocess.Popen([#'ibrun',
#'-n',
#'1',
'python',
'/home/kopec/CGM-sim-analysis/sightline_analysis.py',
filename])
return proc
filenames = glob.glob("DD????/DD????")
for filename in yt.parallel_objects(filenames):
#print("Parent CPU:", os.sched_getaffinity(0))
rays_bad = True
tries = 1
while rays_bad and tries <= 20:
proc = launch_subprocess(filename)
print("Rank", rank, "launched", filename, "on pid", proc.pid, "for try", tries, flush=True)
proc.wait() # wait for subprocces to finish
print("Rank", rank, "pip", proc.pid, "returncode:", proc.returncode, flush=True)
rays_bad = proc.returncode # anything but 0 is failure
tries += 1
print("Rank", rank, "finished file", filename, flush=True)