本文整理汇总了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
示例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
示例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