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

Function test_worker_crash

tests/test_worker.py:1110–1138  ·  view source on GitHub ↗
(mocker, worker, exception_thrown)

Source from the content-addressed store, hash-verified

1108 ],
1109)
1110async def test_worker_crash(mocker, worker, exception_thrown):
1111 # Testing redis exceptions, no retry settings specified
1112 worker = worker(functions=[func(foobar)])
1113
1114 # patch db read_response to mimic connection exceptions
1115 p = patch.object(worker.pool.connection_pool.connection_class, 'read_response', side_effect=exception_thrown)
1116
1117 # baseline
1118 await worker.main()
1119 await worker._poll_iteration()
1120
1121 # spy method handling call_with_retry failure
1122 spy = mocker.spy(worker.pool, '_disconnect_raise')
1123
1124 try:
1125 # start patch
1126 p.start()
1127
1128 # assert exception thrown
1129 with pytest.raises(type(exception_thrown)):
1130 await worker._poll_iteration()
1131
1132 # assert no retry counts and exception thrown during '_disconnect_raise'
1133 assert spy.call_count == 1
1134 assert spy.spy_exception == exception_thrown
1135
1136 finally:
1137 # stop patch to allow worker cleanup
1138 p.stop()

Callers

nothing calls this directly

Calls 4

funcFunction · 0.90
workerFunction · 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…