Browse Source

Merge branch 'v3' of github.com:jumpserver/jumpserver into v3

pull/9239/head
Bai 2 years ago
parent
commit
4aed287efc
  1. 14
      apps/ops/signal_handlers.py

14
apps/ops/signal_handlers.py

@ -1,17 +1,15 @@
import ast
from celery import signals
from django.db import transaction
from celery import signals
from django.core.cache import cache
from django.db import transaction
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.db.utils import ProgrammingError
from django.dispatch import receiver
from django.utils import translation, timezone
from django.utils.translation import gettext as _
from common.signals import django_ready
from common.db.utils import close_old_connections, get_logger
from .celery import app
from .models import CeleryTaskExecution, CeleryTask, Job
@ -27,8 +25,12 @@ def on_account_pre_create(sender, instance, **kwargs):
instance.version += 1
@receiver(django_ready)
@receiver(signals.worker_ready)
def sync_registered_tasks(*args, **kwargs):
synced = cache.get('synced_registered_tasks', False)
if synced:
return
cache.set('synced_registered_tasks', True, 60)
with transaction.atomic():
try:
db_tasks = CeleryTask.objects.all()

Loading…
Cancel
Save