Skip to content

Commit 1cff32c

Browse files
committed
Don't change key for locks
1 parent 0e2a4fb commit 1cff32c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

tasktiger/_internal.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,14 @@ def gen_unique_id(queue, serialized_name, args, kwargs):
6262
Generates and returns a hex-encoded 256-bit ID for the given task name and
6363
args. Used to generate IDs for unique tasks or for task locks.
6464
"""
65-
return hashlib.sha256(
66-
json.dumps(
67-
{
68-
'queue': queue,
69-
'func': serialized_name,
70-
'args': args,
71-
'kwargs': kwargs,
72-
},
73-
sort_keys=True,
74-
).encode('utf8')
75-
).hexdigest()
65+
data = {
66+
'func': serialized_name,
67+
'args': args,
68+
'kwargs': kwargs,
69+
}
70+
if queue is not None:
71+
data['queue'] = queue
72+
return hashlib.sha256(json.dumps(data, sort_keys=True).encode('utf8')).hexdigest()
7673

7774

7875
def serialize_func_name(func):

tasktiger/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,14 @@ def _execute_task_group(self, queue, tasks, all_task_ids, queue_lock):
857857
if task.lock_key:
858858
kwargs = task.kwargs
859859
lock_id = gen_unique_id(
860+
None,
860861
task.serialized_func,
861862
None,
862863
{key: kwargs.get(key) for key in task.lock_key},
863864
)
864865
else:
865866
lock_id = gen_unique_id(
866-
task.serialized_func, task.args, task.kwargs
867+
None, task.serialized_func, task.args, task.kwargs
867868
)
868869

869870
if lock_id not in lock_ids:

0 commit comments

Comments
 (0)