From da0c017c4f27005887d71843c80e48bbd80ddddd Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Wed, 15 May 2024 14:03:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ldap=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=9C=AA=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/tasks.py | 14 +++++++------- apps/settings/tasks/ldap.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/ops/tasks.py b/apps/ops/tasks.py index 3da3b726e..6292df69d 100644 --- a/apps/ops/tasks.py +++ b/apps/ops/tasks.py @@ -144,10 +144,10 @@ def clean_job_execution_period(): del_res = JobExecution.objects.filter(date_created__lt=expired_day).delete() logger.info(f"clean job_execution db record success! delete {days} days {del_res[0]} records") - -@shared_task -def longtime_add(x, y): - print('long time task begins') - time.sleep(50) - print('long time task finished') - return x + y +# 测试使用,注释隐藏 +# @shared_task +# def longtime_add(x, y): +# print('long time task begins') +# time.sleep(50) +# print('long time task finished') +# return x + y diff --git a/apps/settings/tasks/ldap.py b/apps/settings/tasks/ldap.py index 856389512..e600017cb 100644 --- a/apps/settings/tasks/ldap.py +++ b/apps/settings/tasks/ldap.py @@ -9,7 +9,7 @@ from common.utils import get_logger from common.utils.timezone import local_now_display from ops.celery.decorator import after_app_ready_start from ops.celery.utils import ( - create_or_update_celery_periodic_tasks, disable_celery_periodic_task + create_or_update_celery_periodic_tasks, delete_celery_periodic_task ) from orgs.models import Organization from settings.notifications import LDAPImportMessage @@ -69,6 +69,7 @@ def import_ldap_user_periodic(): if not settings.AUTH_LDAP: return task_name = 'import_ldap_user_periodic' + delete_celery_periodic_task(task_name) if not settings.AUTH_LDAP_SYNC_IS_PERIODIC: return @@ -85,8 +86,7 @@ def import_ldap_user_periodic(): task_name: { 'task': import_ldap_user.name, 'interval': interval, - 'crontab': crontab, - 'enabled': True, + 'crontab': crontab } } create_or_update_celery_periodic_tasks(tasks)