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

Function test_worker_retry

tests/test_worker.py:1072–1100  ·  view source on GitHub ↗
(mocker, worker_retry, exception_thrown)

Source from the content-addressed store, hash-verified

1070 ],
1071)
1072async def test_worker_retry(mocker, worker_retry, exception_thrown):
1073 # Testing redis exceptions, with retry settings specified
1074 worker = worker_retry(functions=[func(foobar)])
1075
1076 # patch db read_response to mimic connection exceptions
1077 p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown)
1078
1079 # baseline
1080 await worker.main()
1081 await worker._poll_iteration()
1082
1083 # spy method handling call_with_retry failure
1084 spy = mocker.spy(worker.pool, '_disconnect_raise')
1085
1086 try:
1087 # start patch
1088 p.start()
1089
1090 # assert exception thrown
1091 with pytest.raises(type(exception_thrown)):
1092 await worker._poll_iteration()
1093
1094 # assert retry counts and no exception thrown during '_disconnect_raise'
1095 assert spy.call_count == 4 # retries setting + 1
1096 assert spy.spy_exception is None
1097
1098 finally:
1099 # stop patch to allow worker cleanup
1100 p.stop()
1101
1102
1103@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

funcFunction · 0.90
worker_retryFunction · 0.85
mainMethod · 0.80
_poll_iterationMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…