[Update] 修复取消 LDAP 同步用户任务失败的问题

This commit is contained in:
BaiJiangJie
2019-11-11 18:50:05 +08:00
parent fc58906bce
commit 78a7bfbd30
2 changed files with 7 additions and 3 deletions

View File

@@ -1,10 +1,13 @@
# -*- coding: utf-8 -*-
#
import sys
from celery import shared_task
from django.conf import settings
from ops.celery.utils import create_or_update_celery_periodic_tasks
from ops.celery.utils import (
create_or_update_celery_periodic_tasks, disable_celery_periodic_task
)
from ops.celery.decorator import after_app_ready_start
from common.utils import get_logger
from .models import User
@@ -88,6 +91,8 @@ def import_ldap_user_periodic():
if not settings.AUTH_LDAP:
return
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
task_name = sys._getframe().f_code.co_name
disable_celery_periodic_task(task_name)
return
interval = settings.AUTH_LDAP_SYNC_INTERVAL