MCPcopy Create free account
hub / github.com/python-arq/arq / test_job_timeout

Function test_job_timeout

tests/test_worker.py:973–988  ·  view source on GitHub ↗
(arq_redis: ArqRedis, worker, caplog)

Source from the content-addressed store, hash-verified

971
972
973async def test_job_timeout(arq_redis: ArqRedis, worker, caplog):
974 async def longfunc(ctx):
975 await asyncio.sleep(0.3)
976
977 caplog.set_level(logging.ERROR)
978 await arq_redis.enqueue_job('longfunc', _job_id='testing')
979 worker: Worker = worker(functions=[func(longfunc, name='longfunc')], job_timeout=0.2, poll_delay=0.1)
980 assert worker.jobs_complete == 0
981 assert worker.jobs_failed == 0
982 assert worker.jobs_retried == 0
983 await worker.main()
984 assert worker.jobs_complete == 0
985 assert worker.jobs_failed == 1
986 assert worker.jobs_retried == 0
987 log = re.sub(r'\d+.\d\ds', 'X.XXs', '\n'.join(r.message for r in caplog.records))
988 assert 'X.XXs ! testing:longfunc failed, TimeoutError:' in log
989
990
991async def test_on_job(arq_redis: ArqRedis, worker):

Callers

nothing calls this directly

Calls 4

funcFunction · 0.90
workerFunction · 0.85
enqueue_jobMethod · 0.80
mainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…