本文整理汇总了Python中collector.lib.util.DotDict.maximum_queue_size方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.maximum_queue_size方法的具体用法?Python DotDict.maximum_queue_size怎么用?Python DotDict.maximum_queue_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collector.lib.util.DotDict
的用法示例。
在下文中一共展示了DotDict.maximum_queue_size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_doing_work_with_two_workers_and_generator
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [as 别名]
def test_doing_work_with_two_workers_and_generator(self):
config = DotDict()
config.logger = self.logger
config.number_of_threads = 2
config.maximum_queue_size = 2
my_list = []
def insert_into_list(anItem):
my_list.append(anItem)
ttm = ThreadedTaskManager(config,
task_func=insert_into_list,
job_source_iterator=(((x,), {}) for x in
xrange(10))
)
try:
ttm.start()
time.sleep(0.2)
ok_(len(ttm.thread_list) == 2,
"expected 2 threads, but found %d"
% len(ttm.thread_list))
ok_(len(my_list) == 10,
'expected to do 10 inserts, '
'but %d were done instead' % len(my_list))
ok_(sorted(my_list) == range(10),
'expected %s, but got %s' % (range(10),
sorted(my_list)))
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例2: test_doing_work_with_one_worker
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [as 别名]
def test_doing_work_with_one_worker(self):
config = DotDict()
config.logger = self.logger
config.number_of_threads = 1
config.maximum_queue_size = 1
my_list = []
def insert_into_list(anItem):
my_list.append(anItem)
ttm = ThreadedTaskManager(config,
task_func=insert_into_list
)
try:
ttm.start()
time.sleep(0.2)
ok_(len(my_list) == 10,
'expected to do 10 inserts, '
'but %d were done instead' % len(my_list))
ok_(my_list == range(10),
'expected %s, but got %s' % (range(10), my_list))
ttm.stop()
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例3: test_constuctor1
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [as 别名]
def test_constuctor1(self):
config = DotDict()
config.logger = self.logger
config.number_of_threads = 1
config.maximum_queue_size = 1
ttm = ThreadedTaskManager(config)
try:
ok_(ttm.config == config)
ok_(ttm.logger == self.logger)
ok_(ttm.task_func == default_task_func)
ok_(ttm.quit == False)
finally:
# we got threads to join
ttm._kill_worker_threads()
示例4: test_blocking_start_with_quit_on_empty
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [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
)
示例5: test_start1
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [as 别名]
def test_start1(self):
config = DotDict()
config.logger = self.logger
config.number_of_threads = 1
config.maximum_queue_size = 1
ttm = ThreadedTaskManager(config)
try:
ttm.start()
time.sleep(0.2)
ok_(ttm.queuing_thread.isAlive(),
"the queing thread is not running")
ok_(len(ttm.thread_list) == 1,
"where's the worker thread?")
ok_(ttm.thread_list[0].isAlive(),
"the worker thread is stillborn")
ttm.stop()
ok_(ttm.queuing_thread.isAlive() == False,
"the queuing thread did not stop")
except Exception:
# we got threads to join
ttm.wait_for_completion()
示例6: test_task_raises_unexpected_exception
# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import maximum_queue_size [as 别名]
def test_task_raises_unexpected_exception(self):
global count
count = 0
def new_iter():
for x in xrange(10):
yield (x,)
my_list = []
def insert_into_list(anItem):
global count
count += 1
if count == 4:
raise Exception('Unexpected')
my_list.append(anItem)
config = DotDict()
config.logger = self.logger
config.number_of_threads = 1
config.maximum_queue_size = 1
config.job_source_iterator = new_iter
config.task_func = insert_into_list
ttm = ThreadedTaskManagerWithConfigSetup(config)
try:
ttm.start()
time.sleep(0.2)
ok_(len(ttm.thread_list) == 1,
"expected 1 threads, but found %d"
% len(ttm.thread_list))
ok_(sorted(my_list) == [0, 1, 2, 4, 5, 6, 7, 8, 9],
'expected %s, but got %s'
% ([0, 1, 2, 5, 6, 7, 8, 9], sorted(my_list)))
ok_(len(my_list) == 9,
'expected to do 9 inserts, '
'but %d were done instead' % len(my_list))
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise