本文整理匯總了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)
示例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)
示例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)
示例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)
示例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)
示例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'])
示例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)
示例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]
示例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)