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

Function test_mung

tests/test_main.py:168–188  ·  view source on GitHub ↗

check a job can't be enqueued multiple times with the same id

(arq_redis: ArqRedis, worker)

Source from the content-addressed store, hash-verified

166
167
168async def test_mung(arq_redis: ArqRedis, worker):
169 """
170 check a job can't be enqueued multiple times with the same id
171 """
172 counter = Counter()
173
174 async def count(ctx, v):
175 counter[v] += 1
176
177 tasks = []
178 for i in range(50):
179 tasks += [
180 arq_redis.enqueue_job('count', i, _job_id=f'v-{i}'),
181 arq_redis.enqueue_job('count', i, _job_id=f'v-{i}'),
182 ]
183 shuffle(tasks)
184 await asyncio.gather(*tasks)
185
186 worker: Worker = worker(functions=[func(count, name='count')])
187 await worker.main()
188 assert counter.most_common(1)[0][1] == 1 # no job go enqueued twice
189
190
191async def test_custom_try(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…