def init_lmon(self, attach, **kwargs): """Initialize LaunchMON and deploy back-end daemons. attach is True to attach to a process. - Provide the keyword argument pid, the srun PID. attach is False to launch the job. - Provide keyword arguments launcher and launcher_args. """ os.environ.update(gdbconf.environ) self.lmon = LMON_fe() try: self.lmon.init() self.lmon_session = self.lmon.createSession() self.lmon.putToBeDaemonEnv(self.lmon_session, gdbconf.environ.items()) self.lmon.regPackForFeToBe(self.lmon_session, lmon.pack) self.lmon.regUnpackForBeToFe(self.lmon_session, lmon.unpack) if attach: host = kwargs["host"] if not host: host = socket.getfqdn() self.lmon.attachAndSpawnDaemons(self.lmon_session, host, kwargs["pid"], gdbconf.backend_bin, gdbconf.backend_args, None, None) else: launcher_argv = [kwargs["launcher"]] + kwargs["launcher_args"] self.lmon.launchAndSpawnDaemons(self.lmon_session, socket.getfqdn(), kwargs["launcher"], launcher_argv, gdbconf.backend_bin, gdbconf.backend_args, None, None) self.proctab_size = self.lmon.getProctableSize(self.lmon_session) self.proctab, unused = self.lmon.getProctable( self.lmon_session, self.proctab_size) except lmon.LMONException as e: e.print_lmon_error() traceback.print_exc() return False # These are meaningless for the front-end. self.lmon_rank = None self.lmon_size = None self.lmon_master = None self._init_mpiranks() return True