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

Function test_handle_sig

tests/test_worker.py:77–93  ·  view source on GitHub ↗
(caplog, arq_redis: ArqRedis)

Source from the content-addressed store, hash-verified

75
76
77async def test_handle_sig(caplog, arq_redis: ArqRedis):
78 caplog.set_level(logging.INFO)
79 worker = Worker([foobar], redis_pool=arq_redis)
80 worker.main_task = MagicMock()
81 worker.tasks = {0: MagicMock(done=MagicMock(return_value=True)), 1: MagicMock(done=MagicMock(return_value=False))}
82
83 assert len(caplog.records) == 0
84 worker.handle_sig(signal.SIGINT)
85 assert len(caplog.records) == 1
86 assert caplog.records[0].message == (
87 'shutdown on SIGINT ◆ 0 jobs complete ◆ 0 failed ◆ 0 retries ◆ 2 ongoing to cancel'
88 )
89 assert worker.main_task.cancel.call_count == 1
90 assert worker.tasks[0].done.call_count == 1
91 assert worker.tasks[0].cancel.call_count == 0
92 assert worker.tasks[1].done.call_count == 1
93 assert worker.tasks[1].cancel.call_count == 1
94
95
96async def test_handle_no_sig(caplog):

Callers

nothing calls this directly

Calls 2

handle_sigMethod · 0.95
WorkerClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…