lib.py 文件源码

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

项目:FogLAMP 作者: foglamp 项目源码 文件源码
def _check_semaphore_file(cls, file_name):
        """ Evaluates if a specific either backup or restore operation is in execution

        Args:
            file_name: semaphore file, full path
        Returns:
            pid: 0= no operation is in execution or the pid retrieved from the semaphore file
        Raises:
        """

        _logger.debug("{func}".format(func="check_semaphore_file"))

        pid = 0

        if os.path.exists(file_name):
            pid = cls._pid_file_retrieve(file_name)

            # Check if the process is really running
            try:
                os.getpgid(pid)
            except ProcessLookupError:
                # Process is not running, removing the semaphore file
                os.remove(file_name)

                _message = _MESSAGES_LIST["e000002"].format(file_name, pid)
                _logger.warning("{0}".format(_message))

                pid = 0

        return pid
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号