本文整理汇总了Python中socorro.lib.util.DotDict.logger方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.logger方法的具体用法?Python DotDict.logger怎么用?Python DotDict.logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.lib.util.DotDict
的用法示例。
在下文中一共展示了DotDict.logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_doing_work_with_two_workers_and_config_setup
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def test_doing_work_with_two_workers_and_config_setup(self):
def new_iter():
for x in xrange(5):
yield ((x,), {})
my_list = []
def insert_into_list(anItem):
my_list.append(anItem)
config = DotDict()
config.logger = self.logger
config.number_of_threads = 2
config.maximum_queue_size = 2
config.job_source_iterator = new_iter
config.task_func = insert_into_list
ttm = ThreadedTaskManagerWithConfigSetup(config)
try:
ttm.start()
time.sleep(0.2)
self.assertTrue(len(ttm.thread_list) == 2,
"expected 2 threads, but found %d"
% len(ttm.thread_list))
self.assertTrue(len(my_list) == 5,
'expected to do 5 inserts, '
'but %d were done instead' % len(my_list))
self.assertTrue(sorted(my_list) == range(5),
'expected %s, but got %s' % (range(5),
sorted(my_list)))
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例2: test_doing_work_with_two_workers_and_config_setup
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def test_doing_work_with_two_workers_and_config_setup(self):
def new_iter():
for x in xrange(5):
yield ((x,), {})
my_list = []
def insert_into_list(anItem):
my_list.append(anItem)
config = DotDict()
config.logger = self.logger
config.number_of_threads = 2
config.maximum_queue_size = 2
config.job_source_iterator = new_iter
config.task_func = insert_into_list
ttm = ThreadedTaskManagerWithConfigSetup(config)
try:
ttm.start()
time.sleep(0.2)
assert len(ttm.thread_list) == 2
assert len(my_list) == 5
assert sorted(my_list) == list(range(5))
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例3: test_task_raises_unexpected_exception
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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)
assert len(ttm.thread_list) == 1
assert sorted(my_list) == [0, 1, 2, 4, 5, 6, 7, 8, 9]
assert len(my_list) == 9
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例4: test_doing_work_with_two_workers_and_generator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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
示例5: test_doing_work_with_one_worker
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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
示例6: test_get_iterator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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()])
示例7: test_get_iterator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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),
)
assert tm._get_iterator() == [0]
def an_iter(self):
for i in range(5):
yield i
tm = TaskManager(
config,
job_source_iterator=an_iter,
)
assert list(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)
)
assert list(tm._get_iterator()) == list(config.keys())
示例8: test_blocking_start
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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)
示例9: test_doing_work_with_two_workers_and_generator
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [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)
assert len(ttm.thread_list) == 2
assert len(my_list) == 10
assert sorted(my_list) == list(range(10))
except Exception:
# we got threads to join
ttm.wait_for_completion()
raise
示例10: _setup_config
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def _setup_config(self):
config = DotDict();
config.rabbitmq_class = Mock()
config.transaction_executor_class = Mock()
config.logger = Mock()
config.routing_key = 'socorro.normal'
config.filter_on_legacy_processing = True
return config
示例11: test_constuctor1
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def test_constuctor1(self):
config = DotDict()
config.logger = self.logger
tm = TaskManager(config)
ok_(tm.config == config)
ok_(tm.logger == self.logger)
ok_(tm.task_func == default_task_func)
ok_(tm.quit == False)
示例12: test_constuctor1
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def test_constuctor1(self):
config = DotDict()
config.logger = self.logger
config.quit_on_empty_queue = False
tm = TaskManager(config)
assert tm.config == config
assert tm.logger == self.logger
assert tm.task_func == default_task_func
assert tm.quit == False
示例13: _setup_config
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def _setup_config(self):
config = DotDict()
config.transaction_executor_class = Mock()
config.logger = Mock()
config.rabbitmq_class = MagicMock()
config.routing_key = 'socorro.normal'
config.filter_on_legacy_processing = True
config.redactor_class = Redactor
config.forbidden_keys = Redactor.required_config.forbidden_keys.default
return config
示例14: test_executor_identity
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def test_executor_identity(self):
config = DotDict()
config.logger = self.logger
tm = TaskManager(
config,
job_source_iterator=range(1),
)
tm._pid = 666
eq_(tm.executor_identity(), '666-MainThread')
示例15: _setup_config
# 需要导入模块: from socorro.lib.util import DotDict [as 别名]
# 或者: from socorro.lib.util.DotDict import logger [as 别名]
def _setup_config(self):
config = DotDict()
config.transaction_executor_class = Mock()
config.backoff_delays = (0, 0, 0)
config.logger = Mock()
config.rabbitmq_class = MagicMock()
config.routing_key = "socorro.normal"
config.filter_on_legacy_processing = True
config.redactor_class = Redactor
config.forbidden_keys = Redactor.required_config.forbidden_keys.default
config.throttle = 100
return config