當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。