mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-10-23 16:59:08 +00:00
Fixed TG messages quotes. Fixed sync tasks loop.
This commit is contained in:
@@ -481,6 +481,7 @@ class ServerAdmin(PolymorphicParentModelAdmin, BaseVPNAdmin):
|
||||
task_key = f"sync_server_{server.id}"
|
||||
|
||||
# Use Celery's inspect to check active tasks (optional, for better UX)
|
||||
try:
|
||||
inspect = current_app.control.inspect()
|
||||
active_tasks = inspect.active()
|
||||
|
||||
@@ -489,8 +490,10 @@ class ServerAdmin(PolymorphicParentModelAdmin, BaseVPNAdmin):
|
||||
if active_tasks:
|
||||
for worker, tasks in active_tasks.items():
|
||||
for task_info in tasks:
|
||||
if task_info.get('name') == 'sync_server_users' and \
|
||||
server.id in str(task_info.get('args', [])):
|
||||
if task_info.get('name') == 'sync_server_users':
|
||||
# Check if server.id is in the task args
|
||||
task_args = task_info.get('args', [])
|
||||
if task_args and len(task_args) > 0 and task_args[0] == server.id:
|
||||
task_already_running = True
|
||||
break
|
||||
|
||||
@@ -501,6 +504,9 @@ class ServerAdmin(PolymorphicParentModelAdmin, BaseVPNAdmin):
|
||||
level=messages.WARNING
|
||||
)
|
||||
continue
|
||||
except Exception as e:
|
||||
# If we can't check active tasks, just proceed
|
||||
logger.debug(f"Could not check active tasks: {e}")
|
||||
|
||||
# Avoid scheduling duplicate tasks in this batch
|
||||
if server.id in scheduled_tasks:
|
||||
|
Reference in New Issue
Block a user