当前位置: 首页>>代码示例>>Python>>正文


Python utils.exception_message函数代码示例

本文整理汇总了Python中tooz.utils.exception_message函数的典型用法代码示例。如果您正苦于以下问题:Python exception_message函数的具体用法?Python exception_message怎么用?Python exception_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了exception_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _translate_failures

def _translate_failures():
    """Translates common redis exceptions into tooz exceptions."""
    try:
        yield
    except (exceptions.ConnectionError, exceptions.TimeoutError) as e:
        raise coordination.ToozConnectionError(utils.exception_message(e))
    except exceptions.RedisError as e:
        raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:8,代码来源:redis.py

示例2: _update_capabilities_handler

 def _update_capabilities_handler(async_result, timeout,
                                  timeout_exception, group_id, member_id):
     try:
         async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NoNodeError:
         raise coordination.MemberNotJoined(group_id, member_id)
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:10,代码来源:zookeeper.py

示例3: _get_groups_handler

 def _get_groups_handler(async_result, timeout, timeout_exception):
     try:
         group_ids = async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NoNodeError:
         raise coordination.ToozError("tooz namespace has not been created")
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
     else:
         return set(g.encode('ascii') for g in group_ids)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:11,代码来源:zookeeper.py

示例4: _delete_group_handler

 def _delete_group_handler(async_result, timeout,
                           timeout_exception, group_id):
     try:
         async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NoNodeError:
         raise coordination.GroupNotCreated(group_id)
     except exceptions.NotEmptyError:
         raise coordination.GroupNotEmpty(group_id)
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:12,代码来源:zookeeper.py

示例5: _join_group_handler

 def _join_group_handler(async_result, timeout,
                         timeout_exception, group_id, member_id):
     try:
         async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NodeExistsError:
         raise coordination.MemberAlreadyExist(group_id, member_id)
     except exceptions.NoNodeError:
         raise coordination.GroupNotCreated(group_id)
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:12,代码来源:zookeeper.py

示例6: _create_group_handler

 def _create_group_handler(async_result, timeout,
                           timeout_exception, group_id):
     try:
         async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NodeExistsError:
         raise coordination.GroupAlreadyExist(group_id)
     except exceptions.NoNodeError:
         raise coordination.ToozError("tooz namespace has not been created")
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:12,代码来源:zookeeper.py

示例7: _get_members_handler

 def _get_members_handler(async_result, timeout,
                          timeout_exception, group_id):
     try:
         members_ids = async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NoNodeError:
         raise coordination.GroupNotCreated(group_id)
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
     else:
         return set(m.encode('ascii') for m in members_ids)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:12,代码来源:zookeeper.py

示例8: _get_member_capabilities_handler

 def _get_member_capabilities_handler(cls, async_result, timeout,
                                      timeout_exception, group_id,
                                      member_id):
     try:
         capabilities = async_result.get(block=True, timeout=timeout)[0]
     except timeout_exception as e:
         raise coordination.OperationTimedOut(utils.exception_message(e))
     except exceptions.NoNodeError:
         raise coordination.MemberNotJoined(group_id, member_id)
     except exceptions.ZookeeperError as e:
         raise coordination.ToozError(utils.exception_message(e))
     else:
         return cls._loads(capabilities)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:13,代码来源:zookeeper.py

示例9: _leave_group_handler

 def _leave_group_handler(async_result, timeout,
                          timeout_exception, group_id, member_id):
     try:
         async_result.get(block=True, timeout=timeout)
     except timeout_exception as e:
         coordination.raise_with_cause(coordination.OperationTimedOut,
                                       utils.exception_message(e),
                                       cause=e)
     except exceptions.NoNodeError:
         raise coordination.MemberNotJoined(group_id, member_id)
     except exceptions.ZookeeperError as e:
         coordination.raise_with_cause(coordination.ToozError,
                                       utils.exception_message(e),
                                       cause=e)
开发者ID:cloudnull,项目名称:tooz,代码行数:14,代码来源:zookeeper.py

示例10: get_connection

    def get_connection(parsed_url, options):
        host = parsed_url.hostname
        port = parsed_url.port
        dbname = parsed_url.path[1:]
        username = parsed_url.username
        password = parsed_url.password
        unix_socket = options.get("unix_socket")

        try:
            if unix_socket:
                return pymysql.Connect(unix_socket=unix_socket,
                                       port=port,
                                       user=username,
                                       passwd=password,
                                       database=dbname)
            else:
                return pymysql.Connect(host=host,
                                       port=port,
                                       user=username,
                                       passwd=password,
                                       database=dbname)
        except (pymysql.err.OperationalError, pymysql.err.InternalError) as e:
            coordination.raise_with_cause(coordination.ToozConnectionError,
                                          utils.exception_message(e),
                                          cause=e)
开发者ID:yunjianfei,项目名称:tooz,代码行数:25,代码来源:mysql.py

示例11: _translate_failures

def _translate_failures():
    try:
        yield
    except EnvironmentError as e:
        coordination.raise_with_cause(coordination.ToozError,
                                      utils.exception_message(e),
                                      cause=e)
开发者ID:cloudnull,项目名称:tooz,代码行数:7,代码来源:file.py

示例12: get

 def get(self, timeout=10):
     try:
         return self._fut.result(timeout=timeout)
     except futures.TimeoutError as e:
         coordination.raise_with_cause(coordination.OperationTimedOut,
                                       utils.exception_message(e),
                                       cause=e)
开发者ID:cloudnull,项目名称:tooz,代码行数:7,代码来源:ipc.py

示例13: _lock

        def _lock():
            # NOTE(sileht): mysql-server (<5.7.5) allows only one lock per
            # connection at a time:
            #  select GET_LOCK("a", 0);
            #  select GET_LOCK("b", 0); <-- this release lock "a" ...
            # Or
            #  select GET_LOCK("a", 0);
            #  select GET_LOCK("a", 0); release and lock again "a"
            #
            # So, we track locally the lock status with self.acquired
            if self.acquired is True:
                if blocking:
                    raise _retry.Retry
                return False

            try:
                with self._conn as cur:
                    cur.execute("SELECT GET_LOCK(%s, 0);", self.name)
                    # Can return NULL on error
                    if cur.fetchone()[0] is 1:
                        self.acquired = True
                        return True
            except pymysql.MySQLError as e:
                coordination.raise_with_cause(coordination.ToozError, utils.exception_message(e), cause=e)

            if blocking:
                raise _retry.Retry
            return False
开发者ID:cloudnull,项目名称:tooz,代码行数:28,代码来源:mysql.py

示例14: acquire

 def acquire(self, blocking=True):
     if blocking is False:
         try:
             cur = self._conn.cursor()
             cur.execute("SELECT GET_LOCK(%s, 0);", self.name)
             # Can return NULL on error
             if cur.fetchone()[0] is 1:
                 return True
             return False
         except pymysql.MySQLError as e:
             raise coordination.ToozError(utils.exception_message(e))
     else:
         def _acquire():
             try:
                 cur = self._conn.cursor()
                 cur.execute("SELECT GET_LOCK(%s, 0);", self.name)
                 if cur.fetchone()[0] is 1:
                     return True
             except pymysql.MySQLError as e:
                 raise coordination.ToozError(utils.exception_message(e))
             raise _retry.Retry
         kwargs = _retry.RETRYING_KWARGS.copy()
         if blocking is not True:
             kwargs['stop_max_delay'] = blocking
         return _retry.Retrying(**kwargs).call(_acquire)
开发者ID:citrix-openstack-build,项目名称:tooz,代码行数:25,代码来源:mysql.py

示例15: release

 def release(self):
     try:
         with self._conn as cur:
             cur.execute("SELECT RELEASE_LOCK(%s);", self.name)
             return cur.fetchone()[0]
     except pymysql.MySQLError as e:
         raise coordination.ToozError(utils.exception_message(e))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:mysql.py


注:本文中的tooz.utils.exception_message函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。