From b585b0379bfc48cb4df81823338b4eb098b70fd0 Mon Sep 17 00:00:00 2001 From: hequan2017 Date: Mon, 28 Sep 2026 14:12:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20246=20=E4=B8=AA=20D?= =?UTF-8?q?ependabot=20=E4=BE=9D=E8=B5=96=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - requirements.txt 由 2019 年 pip freeze 快照重写为直接依赖清单(Python>=3.10) - Django 2.2.4 -> 5.2.16,DRF 3.9.2 -> 3.17.2,channels 2.2 -> 4.3,celery 4.1 -> 5.5 - 移除代码未使用的 apache-airflow/tornado/GitPython/numpy/thrift/lxml/SQLAlchemy/Mako/Werkzeug/gevent/autobahn/ipython 等历史依赖(含 system/tests.py 中的 airflow 示例) - 已停维的 django-rest-swagger/DRF coreapi 文档替换为 drf-spectacular - celery.platforms/C_FORCE_ROOT/CELERYBEAT_SCHEDULE 按 celery 5 规范迁移 - asgi.py 迁移至 channels 4 入口写法;graphene-django 升级至 3.x(schema 增加 fields) - static/js/jquery-3.1.1.min.js(XSS 漏洞)替换为 jquery-3.7.1 并更新模板引用 --- seal/celery.py | 69 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/seal/celery.py b/seal/celery.py index 83b9b69..9a64486 100644 --- a/seal/celery.py +++ b/seal/celery.py @@ -1,34 +1,35 @@ -from __future__ import absolute_import, unicode_literals -import os -from celery.schedules import crontab -from datetime import timedelta -from celery import Celery, platforms - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'seal.settings') - -app = Celery('seal') -app.config_from_object('django.conf:settings', namespace='CELERY') -app.autodiscover_tasks() -platforms.C_FORCE_ROOT = True - - -@app.task(bind=True) -def debug_task(self): - print('Request: {0!r}'.format(self.request)) - - -##定时任务 -app.conf.update( - CELERYBEAT_SCHEDULE={ - 'demo1': { - 'task': 'system.tasks.system_demo', - 'schedule': timedelta(seconds=10), - 'args': [111] - }, - 'demo2': { - 'task': 'system.tasks.system_demo', - 'schedule': crontab(minute=00, hour=00,day_of_month=1), - 'args': [222] - }, - } -) +from __future__ import absolute_import, unicode_literals +import os +from celery.schedules import crontab +from datetime import timedelta +from celery import Celery + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'seal.settings') +# celery 5 移除了 celery.platforms,允许 root 运行改用环境变量 +os.environ.setdefault('C_FORCE_ROOT', 'true') + +app = Celery('seal') +app.config_from_object('django.conf:settings', namespace='CELERY') +app.autodiscover_tasks() + + +@app.task(bind=True) +def debug_task(self): + print('Request: {0!r}'.format(self.request)) + + +##定时任务 +app.conf.update( + beat_schedule={ + 'demo1': { + 'task': 'system.tasks.system_demo', + 'schedule': timedelta(seconds=10), + 'args': [111] + }, + 'demo2': { + 'task': 'system.tasks.system_demo', + 'schedule': crontab(minute=00, hour=00, day_of_month=1), + 'args': [222] + }, + } +)