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


Python monitoring.CommandListener方法代码示例

本文整理汇总了Python中pymongo.monitoring.CommandListener方法的典型用法代码示例。如果您正苦于以下问题:Python monitoring.CommandListener方法的具体用法?Python monitoring.CommandListener怎么用?Python monitoring.CommandListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymongo.monitoring的用法示例。


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

示例1: register

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def register(listener):
    """Register a global event listener.

    :Parameters:
      - `listener`: A subclasses of :class:`CommandListener`,
        :class:`ServerHeartbeatListener`, :class:`ServerListener`, or
        :class:`TopologyListener`.
    """
    if not isinstance(listener, _EventListener):
        raise TypeError("Listeners for %s must be either a "
                        "CommandListener, ServerHeartbeatListener, "
                        "ServerListener, or TopologyListener." % (listener,))
    if isinstance(listener, CommandListener):
        _LISTENERS.command_listeners.append(listener)
    if isinstance(listener, ServerHeartbeatListener):
        _LISTENERS.server_heartbeat_listeners.append(listener)
    if isinstance(listener, ServerListener):
        _LISTENERS.server_listeners.append(listener)
    if isinstance(listener, TopologyListener):
        _LISTENERS.topology_listeners.append(listener)


# Note - to avoid bugs from forgetting which if these is all lowercase and
# which are camelCase, and at the same time avoid having to add a test for
# every command, use all lowercase here and test against command_name.lower(). 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:27,代码来源:monitoring.py

示例2: __init__

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def __init__(self, listeners):
        self.__command_listeners = _LISTENERS.command_listeners[:]
        self.__server_listeners = _LISTENERS.server_listeners[:]
        lst = _LISTENERS.server_heartbeat_listeners
        self.__server_heartbeat_listeners = lst[:]
        self.__topology_listeners = _LISTENERS.topology_listeners[:]
        if listeners is not None:
            for lst in listeners:
                if isinstance(lst, CommandListener):
                    self.__command_listeners.append(lst)
                if isinstance(lst, ServerListener):
                    self.__server_listeners.append(lst)
                if isinstance(lst, ServerHeartbeatListener):
                    self.__server_heartbeat_listeners.append(lst)
                if isinstance(lst, TopologyListener):
                    self.__topology_listeners.append(lst)
        self.__enabled_for_commands = bool(self.__command_listeners)
        self.__enabled_for_server = bool(self.__server_listeners)
        self.__enabled_for_server_heartbeat = bool(
            self.__server_heartbeat_listeners)
        self.__enabled_for_topology = bool(self.__topology_listeners) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:monitoring.py

示例3: __init__

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def __init__(self, listeners):
        self.__command_listeners = _LISTENERS.command_listeners[:]
        self.__server_listeners = _LISTENERS.server_listeners[:]
        lst = _LISTENERS.server_heartbeat_listeners
        self.__server_heartbeat_listeners = lst[:]
        self.__topology_listeners = _LISTENERS.topology_listeners[:]
        self.__cmap_listeners = _LISTENERS.cmap_listeners[:]
        if listeners is not None:
            for lst in listeners:
                if isinstance(lst, CommandListener):
                    self.__command_listeners.append(lst)
                if isinstance(lst, ServerListener):
                    self.__server_listeners.append(lst)
                if isinstance(lst, ServerHeartbeatListener):
                    self.__server_heartbeat_listeners.append(lst)
                if isinstance(lst, TopologyListener):
                    self.__topology_listeners.append(lst)
                if isinstance(lst, ConnectionPoolListener):
                    self.__cmap_listeners.append(lst)
        self.__enabled_for_commands = bool(self.__command_listeners)
        self.__enabled_for_server = bool(self.__server_listeners)
        self.__enabled_for_server_heartbeat = bool(
            self.__server_heartbeat_listeners)
        self.__enabled_for_topology = bool(self.__topology_listeners)
        self.__enabled_for_cmap = bool(self.__cmap_listeners) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:27,代码来源:monitoring.py

示例4: _validate_event_listeners

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def _validate_event_listeners(option, listeners):
    """Validate event listeners"""
    if not isinstance(listeners, abc.Sequence):
        raise TypeError("%s must be a list or tuple" % (option,))
    for listener in listeners:
        if not isinstance(listener, _EventListener):
            raise TypeError("Listeners for %s must be either a "
                            "CommandListener, ServerHeartbeatListener, "
                            "ServerListener, or TopologyListener." % (option,))
    return listeners 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:12,代码来源:monitoring.py

示例5: enabled_for_commands

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def enabled_for_commands(self):
        """Are any CommandListener instances registered?"""
        return self.__enabled_for_commands 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:monitoring.py

示例6: _validate_event_listeners

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def _validate_event_listeners(option, listeners):
    """Validate event listeners"""
    if not isinstance(listeners, Sequence):
        raise TypeError("%s must be a list or tuple" % (option,))
    for listener in listeners:
        if not isinstance(listener, CommandListener):
            raise TypeError("Only subclasses of "
                            "pymongo.monitoring.CommandListener are supported")
    return listeners 
开发者ID:leancloud,项目名称:satori,代码行数:11,代码来源:monitoring.py

示例7: register

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def register(listener):
    """Register a global event listener.

    :Parameters:
      - `listener`: A subclass of :class:`CommandListener`.
    """
    _validate_event_listeners('listener', [listener])
    _LISTENERS.command_listeners.append(listener) 
开发者ID:leancloud,项目名称:satori,代码行数:10,代码来源:monitoring.py

示例8: _validate_event_listeners

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def _validate_event_listeners(option, listeners):
    """Validate event listeners"""
    if not isinstance(listeners, abc.Sequence):
        raise TypeError("%s must be a list or tuple" % (option,))
    for listener in listeners:
        if not isinstance(listener, _EventListener):
            raise TypeError("Listeners for %s must be either a "
                            "CommandListener, ServerHeartbeatListener, "
                            "ServerListener, TopologyListener, or "
                            "ConnectionPoolListener." % (option,))
    return listeners 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:13,代码来源:monitoring.py

示例9: register

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def register(listener):
    """Register a global event listener.

    :Parameters:
      - `listener`: A subclasses of :class:`CommandListener`,
        :class:`ServerHeartbeatListener`, :class:`ServerListener`,
        :class:`TopologyListener`, or :class:`ConnectionPoolListener`.
    """
    if not isinstance(listener, _EventListener):
        raise TypeError("Listeners for %s must be either a "
                        "CommandListener, ServerHeartbeatListener, "
                        "ServerListener, TopologyListener, or "
                        "ConnectionPoolListener." % (listener,))
    if isinstance(listener, CommandListener):
        _LISTENERS.command_listeners.append(listener)
    if isinstance(listener, ServerHeartbeatListener):
        _LISTENERS.server_heartbeat_listeners.append(listener)
    if isinstance(listener, ServerListener):
        _LISTENERS.server_listeners.append(listener)
    if isinstance(listener, TopologyListener):
        _LISTENERS.topology_listeners.append(listener)
    if isinstance(listener, ConnectionPoolListener):
        _LISTENERS.cmap_listeners.append(listener)

# Note - to avoid bugs from forgetting which if these is all lowercase and
# which are camelCase, and at the same time avoid having to add a test for
# every command, use all lowercase here and test against command_name.lower(). 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:29,代码来源:monitoring.py

示例10: _validate_event_listeners

# 需要导入模块: from pymongo import monitoring [as 别名]
# 或者: from pymongo.monitoring import CommandListener [as 别名]
def _validate_event_listeners(option, listeners):
    """Validate event listeners"""
    if not isinstance(listeners, Sequence):
        raise TypeError("%s must be a list or tuple" % (option,))
    for listener in listeners:
        if not isinstance(listener, _EventListener):
            raise TypeError("Listeners for %s must be either a "
                            "CommandListener, ServerHeartbeatListener, "
                            "ServerListener, or TopologyListener." % (option,))
    return listeners 
开发者ID:naparuba,项目名称:opsbro,代码行数:12,代码来源:monitoring.py


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