diff --git a/spinach/brokers/redis_scripts/set_concurrency_keys.lua b/spinach/brokers/redis_scripts/set_concurrency_keys.lua index b6585e3..e5e15ee 100644 --- a/spinach/brokers/redis_scripts/set_concurrency_keys.lua +++ b/spinach/brokers/redis_scripts/set_concurrency_keys.lua @@ -19,11 +19,10 @@ for i=3, #ARGV do if max_concurrency ~= -1 then new_task_names[task["name"]] = true - -- Override max_concurrency whatever it is already set to, if - -- anything. - redis.call('hset', max_concurrency_key, task["name"], max_concurrency) - -- Check to see if current_concurrency exists before initialising - -- it. + -- Check to see if concurrency keys exist before initialising them. + if redis.call('hexists', current_concurrency_key, task["name"]) == 0 then + redis.call('hset', max_concurrency_key, task["name"], max_concurrency) + end if redis.call('hexists', current_concurrency_key, task["name"]) == 0 then redis.call('hset', current_concurrency_key, task["name"], 0) end diff --git a/tests/test_engine.py b/tests/test_engine.py index e5d6b47..52ecf7c 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -56,14 +56,14 @@ def test_schedule_at(patch_now): s = Engine(broker, namespace='tests') s.attach_tasks(tasks) - job = s.schedule_at('bar_task', now, three=True) + job = s.schedule_at('bar_task', now) bar_job = broker.enqueue_jobs.call_args[0][0][0] assert bar_job == job assert bar_job.task_name == 'bar_task' assert bar_job.at == now assert bar_job.task_args == () - assert bar_job.task_kwargs == {'three': True} + assert bar_job.task_kwargs == {} def test_schedule(patch_now): @@ -101,7 +101,7 @@ def test_schedule_batch(patch_now): batch = Batch() batch.schedule('foo_task', 1, 2) - batch.schedule_at('bar_task', now, three=True) + batch.schedule_at('bar_task', now) jobs = s.schedule_batch(batch) broker.enqueue_jobs.assert_called_once_with([ANY, ANY]) @@ -118,7 +118,7 @@ def test_schedule_batch(patch_now): assert bar_job.task_name == 'bar_task' assert bar_job.at == now assert bar_job.task_args == () - assert bar_job.task_kwargs == {'three': True} + assert bar_job.task_kwargs == {} def test_execute(spin): diff --git a/tox.ini b/tox.ini index 8e83d76..2a62ff8 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envdir = py3: {toxworkdir}/py3 pep8: {toxworkdir}/py3 usedevelop = True -whitelist_externals = +allowlist_externals = docker-compose deps = pytest