def __init__(self): if platform.system() == 'Windows': pipe_name = '\\\\.\\pipe\\procd_pipe.' + str(os.getpid()) else: pipe_name = 'procd_pipe' self.drone_tree = DroneTree() init_pid = self.drone_tree.get_init_pid() procd_pid = self.drone_tree.spawn( init_pid, "./condor_procd -A " + pipe_name + " -L procd_log -S -1") self.procd_reference = ProcDReference(init_pid) self.procd_reference.spawn(procd_pid, init_pid) self.procd_interface = ProcDInterface(pipe_name) self.tag_mappings = {'INIT': init_pid, 'PROCD': procd_pid}
import random import sys from procd_test_state import ProcDReference def random_choice(command, choices): if not choices: sys.stderr.write('WARNING: ' + command + ' not possible; skipping\n') return None return random.choice(choices) if __name__ == '__main__': ref = ProcDReference('INIT') next_proc = 0 while True: line = sys.stdin.readline() if not line: break line = line.rstrip() if line == 'SPAWN': parent = random_choice(line, ref.get_all_procs()) if not parent: continue child = 'P' + str(next_proc) next_proc += 1 sys.stdout.write('SPAWN ' + child + ' ' + parent + '\n') ref.spawn(child, parent) elif line == 'KILL':