module_common.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:SiMon 作者: maxwelltsai 项目源码 文件源码
def sim_kill(self):
        """
        Forcibly kill (i.e. terminate) the current simulation. Practically, this method terminates the process of
        the simulation code and sets the simulation status to STOP.

        :return: Return 0 if succeed, -1 if failed. If the simulation is not running, then it cannot be killed, causing
        the method to do nothing but return 1.
        """
        # Find the process by PID
        if self.config.has_option('Simulation', 'PID'):
            pid = self.config.getint('Simulation', 'PID')
            try:
                os.kill(pid, signal.SIGKILL)
                msg = 'Simulation %s (PID: %d) killed.' % (self.name, pid)
                print(msg)
                if self.logger is not None:
                    self.logger.info(msg)
            except OSError, err:
                msg = '%s: Cannot kill the process: %s\n' % (str(err),  self.name)
                print(msg)
                if self.logger is not None:
                    self.logger.warning(msg)
        return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号