當前位置: 首頁>>代碼示例>>Python>>正文


Python _compat.iteritems方法代碼示例

本文整理匯總了Python中redis._compat.iteritems方法的典型用法代碼示例。如果您正苦於以下問題:Python _compat.iteritems方法的具體用法?Python _compat.iteritems怎麽用?Python _compat.iteritems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis._compat的用法示例。


在下文中一共展示了_compat.iteritems方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import iteritems [as 別名]
def __init__(self, sentinels, min_other_sentinels=0, sentinel_kwargs=None,
                 **connection_kwargs):
        # if sentinel_kwargs isn't defined, use the socket_* options from
        # connection_kwargs
        if sentinel_kwargs is None:
            sentinel_kwargs = {
                k: v
                for k, v in iteritems(connection_kwargs)
                if k.startswith('socket_')
            }
        self.sentinel_kwargs = sentinel_kwargs

        self.sentinels = [Redis(hostname, port, **self.sentinel_kwargs)
                          for hostname, port in sentinels]
        self.min_other_sentinels = min_other_sentinels
        self.connection_kwargs = connection_kwargs 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:18,代碼來源:sentinel.py

示例2: run_in_thread

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import iteritems [as 別名]
def run_in_thread(self, sleep_time=0):
        '''
        Replacement for the default PubSub run_in_thread method from
        http://github.com/andymccurdy/redis-py/master/redis/client.py
        '''
        for channel, handler in iteritems(self.channels):
            if handler is None:
                raise PubSubError("Channel: '%s' has no handler registered" % channel)
        for pattern, handler in iteritems(self.channels):
            if handler is None:
                raise PubSubError("Pattern: '%s' has no handler registered" % pattern)
        pubsub = self

        class WorkerThread(threading.Thread):
            ''' Listens for messages on subscriptions '''
            def __init__(self, *args, **kwargs):
                super(WorkerThread, self).__init__(*args, **kwargs)
                self.daemon = True
                self._running = False

            def run(self):
                ''' loop while running on subscriptions '''
                if self._running:
                    return
                self._running = True
                while self._running and pubsub.subscribed:
                    pubsub.get_message(ignore_subscribe_messages=True)
                    mod_time.sleep(sleep_time)

            def stop(self):
                ''' stops the main loop '''
                self._running = False
                self.join()

        thread = WorkerThread()
        thread.start()
        return thread 
開發者ID:hulu,項目名稱:monaco,代碼行數:39,代碼來源:async_pubsub.py

示例3: __init__

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import iteritems [as 別名]
def __init__(self, sentinels, min_other_sentinels=0, sentinel_kwargs=None,
                 **connection_kwargs):
        # if sentinel_kwargs isn't defined, use the socket_* options from
        # connection_kwargs
        if sentinel_kwargs is None:
            sentinel_kwargs = dict([(k, v)
                                    for k, v in iteritems(connection_kwargs)
                                    if k.startswith('socket_')
                                    ])
        self.sentinel_kwargs = sentinel_kwargs

        self.sentinels = [StrictRedis(hostname, port, **self.sentinel_kwargs)
                          for hostname, port in sentinels]
        self.min_other_sentinels = min_other_sentinels
        self.connection_kwargs = connection_kwargs 
開發者ID:leancloud,項目名稱:satori,代碼行數:17,代碼來源:sentinel.py


注:本文中的redis._compat.iteritems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。