Skip to content

Commit

Permalink
Don't change key for locks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasst committed Mar 21, 2021
1 parent 0e2a4fb commit c7d5897
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 8 additions & 9 deletions tasktiger/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ def gen_unique_id(queue, serialized_name, args, kwargs):
Generates and returns a hex-encoded 256-bit ID for the given task name and
args. Used to generate IDs for unique tasks or for task locks.
"""
data = {
'func': serialized_name,
'args': args,
'kwargs': kwargs,
}
if queue is not None:
data['queue'] = queue
return hashlib.sha256(
json.dumps(
{
'queue': queue,
'func': serialized_name,
'args': args,
'kwargs': kwargs,
},
sort_keys=True,
).encode('utf8')
json.dumps(data, sort_keys=True).encode('utf8')
).hexdigest()


Expand Down
3 changes: 2 additions & 1 deletion tasktiger/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,13 +857,14 @@ def _execute_task_group(self, queue, tasks, all_task_ids, queue_lock):
if task.lock_key:
kwargs = task.kwargs
lock_id = gen_unique_id(
None,
task.serialized_func,
None,
{key: kwargs.get(key) for key in task.lock_key},
)
else:
lock_id = gen_unique_id(
task.serialized_func, task.args, task.kwargs
None, task.serialized_func, task.args, task.kwargs
)

if lock_id not in lock_ids:
Expand Down

0 comments on commit c7d5897

Please sign in to comment.