def test_temporaryFailure(self):
"""
When a work item temporarily fails it should appear as unassigned in the JOB
table and have the failure count bumped, and a notBefore set to the temporary delay.
"""
dbpool, _ignore_qpool, clock, _ignore_performerChosen = self._setupPools()
fakeNow = datetime.datetime(2012, 12, 12, 12, 12, 12)
# Let's create a couple of work items directly, not via the enqueue
# method, so that they exist but nobody will try to immediately execute
# them.
@transactionally(dbpool.pool.connection)
@inlineCallbacks
def setup(txn):
# Next, create failing work that's actually far enough into the past to run.
yield DummyWorkItem.makeJob(
txn, a=-2, b=1, notBefore=fakeNow - datetime.timedelta(20 * 60)
)
yield setup
clock.advance(20 - 12)
@transactionally(dbpool.pool.connection)
def check(txn):
return JobItem.all(txn)
jobs = yield check
self.assertTrue(len(jobs) == 1)
self.assertTrue(jobs[0].assigned is None)
self.assertEqual(jobs[0].isAssigned, 0)
self.assertTrue(jobs[0].failed == 1)
self.assertTrue(jobs[0].notBefore > datetime.datetime.utcnow() + datetime.timedelta(seconds=90))
评论列表
文章目录