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,26 +481,32 @@ class ServerAdmin(PolymorphicParentModelAdmin, BaseVPNAdmin):
|
|||||||
task_key = f"sync_server_{server.id}"
|
task_key = f"sync_server_{server.id}"
|
||||||
|
|
||||||
# Use Celery's inspect to check active tasks (optional, for better UX)
|
# Use Celery's inspect to check active tasks (optional, for better UX)
|
||||||
inspect = current_app.control.inspect()
|
try:
|
||||||
active_tasks = inspect.active()
|
inspect = current_app.control.inspect()
|
||||||
|
active_tasks = inspect.active()
|
||||||
# Check if task is already scheduled for this server
|
|
||||||
task_already_running = False
|
# Check if task is already scheduled for this server
|
||||||
if active_tasks:
|
task_already_running = False
|
||||||
for worker, tasks in active_tasks.items():
|
if active_tasks:
|
||||||
for task_info in tasks:
|
for worker, tasks in active_tasks.items():
|
||||||
if task_info.get('name') == 'sync_server_users' and \
|
for task_info in tasks:
|
||||||
server.id in str(task_info.get('args', [])):
|
if task_info.get('name') == 'sync_server_users':
|
||||||
task_already_running = True
|
# Check if server.id is in the task args
|
||||||
break
|
task_args = task_info.get('args', [])
|
||||||
|
if task_args and len(task_args) > 0 and task_args[0] == server.id:
|
||||||
if task_already_running:
|
task_already_running = True
|
||||||
self.message_user(
|
break
|
||||||
request,
|
|
||||||
f"⏳ Sync already in progress for '{server.name}'",
|
if task_already_running:
|
||||||
level=messages.WARNING
|
self.message_user(
|
||||||
)
|
request,
|
||||||
continue
|
f"⏳ Sync already in progress for '{server.name}'",
|
||||||
|
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
|
# Avoid scheduling duplicate tasks in this batch
|
||||||
if server.id in scheduled_tasks:
|
if server.id in scheduled_tasks:
|
||||||
|
Reference in New Issue
Block a user