

def spawn_process(self, recovery_wid=None):
    'Spawn process.\n\n        Return True if ok, False if the watcher must be stopped\n        '
    if self.is_stopped():
        return True
    if ((not recovery_wid) and (not self.call_hook('before_spawn'))):
        return False
    cmd = util.replace_gnu_args(self.cmd, env=self.env)
    nb_tries = 0
    if self.stream_redirector:
        self.stream_redirector.start()
    while ((nb_tries < self.max_retry) or (self.max_retry == (- 1))):
        process = None
        pipe_stdout = (self.stdout_stream is not None)
        pipe_stderr = (self.stderr_stream is not None)
        ProcCls = self._process_class
        try:
            process = ProcCls(self.name, (recovery_wid or self._nextwid), cmd, args=self.args, working_dir=self.working_dir, shell=self.shell, uid=self.uid, gid=self.gid, env=self.env, rlimits=self.rlimits, executable=self.executable, use_fds=self.use_sockets, watcher=self, pipe_stdout=pipe_stdout, pipe_stderr=pipe_stderr, close_child_stdin=self.close_child_stdin, close_child_stdout=self.close_child_stdout, close_child_stderr=self.close_child_stderr)
            if self.stream_redirector:
                self.stream_redirector.add_redirections(process)
            self.processes[process.pid] = process
            logger.debug('running %s process [pid %d]', self.name, process.pid)
            if (not self.call_hook('after_spawn', pid=process.pid)):
                self.kill_process(process)
                del self.processes[process.pid]
                return False
        except (OSError, ValueError) as e:
            logger.warning('error in %r: %s', self.name, str(e))
        if (process is None):
            nb_tries += 1
            continue
        else:
            self.notify_event('spawn', {
                'process_pid': process.pid,
                'time': process.started,
            })
            return process.started
    return False

dataset/ETHPy150Open circus-tent/circus/circus/watcher.py Watcher.spawn_process/original