本文整理汇总了Python中collector.lib.util.DotDict.quit_on_empty_queue方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.quit_on_empty_queue方法的具体用法?Python DotDict.quit_on_empty_queue怎么用?Python DotDict.quit_on_empty_queue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collector.lib.util.DotDict
的用法示例。
在下文中一共展示了DotDict.quit_on_empty_queue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blocking_start
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import quit_on_empty_queue [as 别名]
def test_blocking_start(self):
config = DotDict()
config.logger = self.logger
config.idle_delay = 1
config.quit_on_empty_queue = False
class MyTaskManager(TaskManager):
def _responsive_sleep(
self,
seconds,
wait_log_interval=0,
wait_reason=''
):
try:
if self.count >= 2:
self.quit = True
self.count += 1
except AttributeError:
self.count = 0
tm = MyTaskManager(
config,
task_func=Mock()
)
waiting_func = Mock()
tm.blocking_start(waiting_func=waiting_func)
eq_(
tm.task_func.call_count,
10
)
eq_(waiting_func.call_count, 0)
示例2: test_constuctor1
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import quit_on_empty_queue [as 别名]
def test_constuctor1(self):
config = DotDict()
config.logger = self.logger
config.quit_on_empty_queue = False
tm = TaskManager(config)
ok_(tm.config == config)
ok_(tm.logger == self.logger)
ok_(tm.task_func == default_task_func)
ok_(tm.quit == False)
示例3: test_blocking_start_with_quit_on_empty
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import quit_on_empty_queue [as 别名]
def test_blocking_start_with_quit_on_empty(self):
config = DotDict()
config.logger = self.logger
config.number_of_threads = 2
config.maximum_queue_size = 2
config.quit_on_empty_queue = True
tm = ThreadedTaskManager(
config,
task_func=Mock()
)
waiting_func = Mock()
tm.blocking_start(waiting_func=waiting_func)
eq_(
tm.task_func.call_count,
10
)
示例4: test_blocking_start_with_quit_on_empty
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import quit_on_empty_queue [as 别名]
def test_blocking_start_with_quit_on_empty(self):
config = DotDict()
config.logger = self.logger
config.idle_delay = 1
config.quit_on_empty_queue = True
tm = TaskManager(
config,
task_func=Mock()
)
waiting_func = Mock()
tm.blocking_start(waiting_func=waiting_func)
eq_(
tm.task_func.call_count,
10
)
eq_(waiting_func.call_count, 0)
示例5: test_get_iterator
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import quit_on_empty_queue [as 别名]
def test_get_iterator(self):
config = DotDict()
config.logger = self.logger
config.quit_on_empty_queue = False
tm = TaskManager(
config,
job_source_iterator=range(1),
)
eq_(tm._get_iterator(), [0])
def an_iter(self):
for i in range(5):
yield i
tm = TaskManager(
config,
job_source_iterator=an_iter,
)
eq_(
[x for x in tm._get_iterator()],
[0, 1, 2, 3, 4]
)
class X(object):
def __init__(self, config):
self.config = config
def __iter__(self):
for key in self.config:
yield key
tm = TaskManager(
config,
job_source_iterator=X(config)
)
eq_(
[x for x in tm._get_iterator()],
[y for y in config.keys()]
)