当前位置: 首页>>代码示例>>Python>>正文


Python DotDict.logger方法代码示例

本文整理汇总了Python中collector.lib.util.DotDict.logger方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.logger方法的具体用法?Python DotDict.logger怎么用?Python DotDict.logger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在collector.lib.util.DotDict的用法示例。


在下文中一共展示了DotDict.logger方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_doing_work_with_one_worker

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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
开发者ID:willkg,项目名称:socorro-collector,代码行数:28,代码来源:test_threaded_task_manager.py

示例2: test_doing_work_with_two_workers_and_generator

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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
开发者ID:willkg,项目名称:socorro-collector,代码行数:33,代码来源:test_threaded_task_manager.py

示例3: test_blocking_start

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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)
开发者ID:willkg,项目名称:socorro-collector,代码行数:36,代码来源:test_task_manager.py

示例4: test_executor_identity

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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')
开发者ID:willkg,项目名称:socorro-collector,代码行数:12,代码来源:test_task_manager.py

示例5: test_constuctor1

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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)
        ok_(tm.config == config)
        ok_(tm.logger == self.logger)
        ok_(tm.task_func == default_task_func)
        ok_(tm.quit == False)
开发者ID:willkg,项目名称:socorro-collector,代码行数:12,代码来源:test_task_manager.py

示例6: _setup_config

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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
开发者ID:willkg,项目名称:socorro-collector,代码行数:14,代码来源:test_crashstorage.py

示例7: test_constuctor1

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [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()
开发者ID:willkg,项目名称:socorro-collector,代码行数:16,代码来源:test_threaded_task_manager.py

示例8: _setup_config

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [as 别名]
    def _setup_config(self):
        config = DotDict();
        config.host = 'localhost'
        config.virtual_host = '/'
        config.port = '5672'
        config.rabbitmq_user = 'guest'
        config.rabbitmq_password = 'guest'
        config.standard_queue_name = 'dwight'
        config.priority_queue_name = 'wilma'
        config.reprocessing_queue_name = 'betty'
        config.rabbitmq_connection_wrapper_class = Connection
        config.logger = Mock()

        config.executor_identity = lambda: 'MainThread'

        return config
开发者ID:willkg,项目名称:socorro-collector,代码行数:18,代码来源:test_connection_context.py

示例9: test_blocking_start_with_quit_on_empty

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [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
        )
开发者ID:willkg,项目名称:socorro-collector,代码行数:22,代码来源:test_threaded_task_manager.py

示例10: test_blocking_start_with_quit_on_empty

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [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)
开发者ID:willkg,项目名称:socorro-collector,代码行数:22,代码来源:test_task_manager.py

示例11: test_start1

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [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()
开发者ID:willkg,项目名称:socorro-collector,代码行数:23,代码来源:test_threaded_task_manager.py

示例12: test_task_raises_unexpected_exception

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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)
            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
开发者ID:willkg,项目名称:socorro-collector,代码行数:42,代码来源:test_threaded_task_manager.py

示例13: test_get_iterator

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.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()]
        )
开发者ID:willkg,项目名称:socorro-collector,代码行数:42,代码来源:test_task_manager.py

示例14: testLegacyThrottler

# 需要导入模块: from collector.lib.util import DotDict [as 别名]
# 或者: from collector.lib.util.DotDict import logger [as 别名]
def testLegacyThrottler():

    # phase 1 tests

    config = DotDict()
    config.throttle_conditions = [ ('alpha', re.compile('ALPHA'), 100),
                                   ('beta',  'BETA', 100),
                                   ('gamma', lambda x: x == 'GAMMA', 100),
                                   ('delta', True, 100),
                                   (None, True, 0)
                                  ]
    config.minimal_version_for_understanding_refusal = {
      'product1': '3.5',
      'product2': '4.0'
    }
    config.never_discard = False
    config.logger = mock.Mock()
    thr = LegacyThrottler(config)
    expected = 5
    actual = len(thr.processed_throttle_conditions)
    assert expected == actual, \
      "expected thr.preprocessThrottleConditions to have length %d, but got " \
      "%d instead" % (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.0',
                          'alpha':'ALPHA',
                          })
    expected = False
    actual = thr.understands_refusal(raw_crash)
    assert expected == actual, \
      "understand refusal expected %d, but got %d instead" % (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'alpha':'ALPHA',
                          })
    expected = True
    actual = thr.understands_refusal(raw_crash)
    assert expected == actual, \
      "understand refusal expected %d, but got %d instead" % (expected, actual)

    expected = (ACCEPT, 100)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "regexp throttle expected %d, but got %d instead" % (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.4',
                          'alpha':'not correct',
                          })
    expected = (DEFER, 0)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "regexp throttle expected %d, but got %d instead" % (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'alpha':'not correct',
                          })
    expected = (DISCARD, 0)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "regexp throttle expected %d, but got %d instead" % (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'beta':'BETA',
                          })
    expected = (ACCEPT, 100)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "string equality throttle expected %d, but got %d instead" % \
      (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'beta':'not BETA',
                          })
    expected = (DISCARD, 0)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "string equality throttle expected %d, but got %d instead" % \
      (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'gamma':'GAMMA',
                          })
    expected = (ACCEPT, 100)
    actual = thr.throttle(raw_crash)
    assert expected == actual, \
      "string equality throttle expected %d, but got %d instead" % \
      (expected, actual)

    raw_crash = DotDict({ 'ProductName':'product1',
                          'Version':'3.6',
                          'gamma':'not GAMMA',
                          })
    expected = (DISCARD, 0)
#.........这里部分代码省略.........
开发者ID:willkg,项目名称:socorro-collector,代码行数:103,代码来源:test_throttler.py


注:本文中的collector.lib.util.DotDict.logger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。