Skip to content

Commit 7394bd8

Browse files
committed
[fix/connection/tasks] Ignore current task instance when checking active tasks - #1204
The _is_update_in_progress function was incorrectly detecting the current Celery task as another running task, causing update_config to exit early. This fix excludes the current task by comparing task IDs, ensuring only other instances for the same device are considered. Added tests to cover same worker (should not skip) and different worker (should skip) scenarios. Fixes #1204
1 parent 1580437 commit 7394bd8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

openwisp_controller/connection/tasks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ def _is_update_in_progress(device_id):
2020
active = current_app.control.inspect().active()
2121
if not active:
2222
return False
23-
current_task_id = current_task.request.id if current_task and current_task.request else None
23+
current_task_id = (
24+
current_task.request.id if current_task and current_task.request else None
25+
)
2426
return any(
25-
task["name"] == _TASK_NAME and str(device_id) in task["args"] and task.get("id") != current_task_id
27+
task["name"] == _TASK_NAME
28+
and str(device_id) in task["args"]
29+
and task.get("id") != current_task_id
2630
for task_list in active.values()
2731
for task in task_list
2832
)

0 commit comments

Comments
 (0)