当前位置: 首页>>代码示例>>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;未经允许,请勿转载。