Skip to content

Commit

Permalink
fix:修复定时任务的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tahitimoon committed May 20, 2024
1 parent cb5dc27 commit 8c0f54b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions backend/apps/lunarlink/utils/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def update_task(self, task_id):
try:
task_obj = celery_models.PeriodicTask.objects.get(id=task_id)
except celery_models.PeriodicTask.DoesNotExist:
raise TaskNotFound
raise TaskNotFound(f"task {task_id} not found")

crontab = celery_models.CrontabSchedule.objects.filter(
**self.__crontab_time
Expand All @@ -110,10 +110,10 @@ def update_task(self, task_id):
crontab = celery_models.CrontabSchedule.objects.create(
**self.__crontab_time
)
task_obj.save(
name=f"{self.__project}_{self.__name}",
crontab=crontab,
enabled=self.__switch,
args=json.dumps(self.__data, ensure_ascii=False),
kwargs=json.dumps(self.__email, ensure_ascii=False),
)

task_obj.name = f"{self.__project}_{self.__name}"
task_obj.crontab = crontab
task_obj.enabled = self.__switch
task_obj.args = json.dumps(self.__data, ensure_ascii=False)
task_obj.kwargs = json.dumps(self.__email, ensure_ascii=False)
task_obj.save()

0 comments on commit 8c0f54b

Please sign in to comment.