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


Python PillowError.get_errors_to_process方法代码示例

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


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

示例1: test_bulk_reset

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_bulk_reset(self):
        for i in range(0, 5):
            error = create_error(_change(id=i), attempts=const.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS)
            error.save()

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 0)

        PillowError.bulk_reset_attempts(datetime.utcnow())

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 5)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:14,代码来源:test_model.py

示例2: test_bulk_reset_cutoff

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_bulk_reset_cutoff(self):
        for i in range(0, 3):
            error = create_error(_change(id=i), attempts=1)
            if i >= 1:
                error.total_attempts = const.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF + 1
            error.save()

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 0)

        PillowError.bulk_reset_attempts(datetime.utcnow())

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 2)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:16,代码来源:test_model.py

示例3: test_bulk_reset_cutoff

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_bulk_reset_cutoff(self):
        for i in range(0, 3):
            error = create_error({'id': i}, attempts=1)
            if i >= 1:
                error.total_attempts = PillowError.multi_attempts_cutoff() + 1
            error.save()

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 0)

        PillowError.bulk_reset_attempts(datetime.utcnow())

        errors = PillowError.get_errors_to_process(datetime.utcnow()).all()
        self.assertEqual(len(errors), 2)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:16,代码来源:tests.py

示例4: test_get_errors_to_process

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_get_errors_to_process(self):
        # Only re-process errors with
        # current_attempt < const.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS
        date = datetime.utcnow()
        for i in range(0, 5):
            error = create_error(_change(id=i), attempts=i+1)
            error.date_next_attempt = date.replace(day=i+1)
            error.save()

        errors = PillowError.get_errors_to_process(
            date.replace(day=1),
        ).all()
        self.assertEqual(len(errors), 1)

        errors = PillowError.get_errors_to_process(
            date.replace(day=5),
        ).all()
        self.assertEqual(len(errors), 3)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:20,代码来源:test_model.py

示例5: test_get_errors_to_process_queued_update

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_get_errors_to_process_queued_update(self):
        date = datetime.utcnow()
        error = create_error({'id': 1}, attempts=0)
        error.date_next_attempt = date
        error.save()

        errors = PillowError.get_errors_to_process(
            date,
        ).all()
        self.assertEqual(len(errors), 1)

        # check that calling update on the return value has the desired effect
        errors.update(queued=True)

        errors = PillowError.get_errors_to_process(
            date,
        ).all()
        self.assertEqual(len(errors), 0)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:20,代码来源:tests.py

示例6: test_get_errors_to_process_queued

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_get_errors_to_process_queued(self):
        date = datetime.utcnow()
        error = create_error({'id': 1}, attempts=0)
        error.date_next_attempt = date
        error.save()

        queued_error = create_error({'id': 2}, attempts=0)
        queued_error.date_next_attempt = date
        queued_error.queued = True
        queued_error.save()

        errors = PillowError.get_errors_to_process(
            date,
        ).all()
        self.assertEqual(len(errors), 1)
        self.assertEqual(error.id, errors[0]['id'])
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:18,代码来源:tests.py

示例7: test_get_errors_to_process_max_limit

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
    def test_get_errors_to_process_max_limit(self):
        # see settings.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF
        date = datetime.utcnow()

        def make_error(id, current_attempt, total_attempts):
            error = create_error({'id': id})
            error.date_next_attempt = date
            error.current_attempt = current_attempt
            error.total_attempts = total_attempts
            error.save()

        # current_attempts <= limit, total_attempts <= limit
        make_error(
            'to-process1',
            settings.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS,
            settings.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF
        )

        # current_attempts = 0, total_attempts > limit
        make_error(
            'to-process2',
            0,
            settings.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF + 1
        )

        # current_attempts > limit, total_attempts <= limit
        make_error(
            'not-processed1',
            settings.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS + 1,
            settings.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF
        )

        # current_attempts <= limit, total_attempts > limit
        make_error(
            'not-processed2',
            settings.PILLOW_RETRY_QUEUE_MAX_PROCESSING_ATTEMPTS,
            settings.PILLOW_RETRY_MULTI_ATTEMPTS_CUTOFF + 1
        )

        errors = PillowError.get_errors_to_process(date, fetch_full=True).all()
        self.assertEqual(len(errors), 2)
        docs_to_process = {e.doc_id for e in errors}
        self.assertEqual({'to-process1', 'to-process2'}, docs_to_process)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:45,代码来源:tests.py

示例8: _get_items

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
 def _get_items(utcnow):
     errors = PillowError.get_errors_to_process(utcnow=utcnow, limit=1000)
     error_pks = [error['id'] for error in errors]
     PillowError.objects.filter(pk__in=error_pks).update(queued=True)
     return [dict(id=e['id'], key=e['date_next_attempt']) for e in errors]
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:7,代码来源:run_pillow_retry_queue.py

示例9: _get_items

# 需要导入模块: from pillow_retry.models import PillowError [as 别名]
# 或者: from pillow_retry.models.PillowError import get_errors_to_process [as 别名]
 def _get_items(self, utcnow):
     errors = PillowError.get_errors_to_process(
         utcnow=utcnow,
     )
     return (dict(id=e['id'], key=e['date_next_attempt']) for e in errors)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:7,代码来源:run_pillow_retry_queue.py


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