def create_process_in_cgroup(self, config, controller, cgname, cgclassify=True): if cgclassify: child_pid = self.create_process(config) Cgroup.classify(config, controller, cgname, child_pid) else: # use cgexec # To allow for multiple processes to be created, each new process # sleeps for a different amount of time. This lets us uniquely # find each process later in this function sleep_time = len(self.children) + 1 p = mp.Process(target=Process.__cgexec_infinite_loop, args=( config, controller, cgname, sleep_time, )) p.start() self.children.append(p)
def create_threaded_process_in_cgroup(self, config, controller, cgname, threads=2, cgclassify=True): p = mp.Process(target=self.create_threaded_process, args=( config, threads, )) p.start() if cgclassify: Cgroup.classify(config, controller, cgname, p.pid) self.children.append(p) self.children_pids.append(p.pid) return p.pid