本文整理汇总了Python中pyres.worker.Worker.prune_dead_workers方法的典型用法代码示例。如果您正苦于以下问题:Python Worker.prune_dead_workers方法的具体用法?Python Worker.prune_dead_workers怎么用?Python Worker.prune_dead_workers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyres.worker.Worker
的用法示例。
在下文中一共展示了Worker.prune_dead_workers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prune_dead_workers
# 需要导入模块: from pyres.worker import Worker [as 别名]
# 或者: from pyres.worker.Worker import prune_dead_workers [as 别名]
def test_prune_dead_workers(self):
worker = Worker(['basic']) # we haven't registered this worker, so the assertion below holds
assert self.redis.scard('resque:workers') == 0
self.redis.sadd('resque:workers',"%s:%s:%s" % (os.uname()[1],'1','basic'))
self.redis.sadd('resque:workers',"%s:%s:%s" % (os.uname()[1],'2','basic'))
self.redis.sadd('resque:workers',"%s:%s:%s" % (os.uname()[1],'3','basic'))
assert self.redis.scard('resque:workers') == 3
worker.prune_dead_workers()
assert self.redis.scard('resque:workers') == 0
self.redis.sadd('resque:workers',"%s:%s:%s" % ('host-that-does-not-exist','1','basic'))
self.redis.sadd('resque:workers',"%s:%s:%s" % ('host-that-does-not-exist','2','basic'))
self.redis.sadd('resque:workers',"%s:%s:%s" % ('host-that-does-not-exist','3','basic'))
worker.prune_dead_workers()
# the assertion below should hold, because the workers we registered above are on a
# different host, and thus should not be pruned by this process
assert self.redis.scard('resque:workers') == 3