On améliore le redémarrage de Celery

Fix #325
This commit is contained in:
Jean-Marie Favreau 2025-03-01 15:25:54 +01:00
parent f9a72a4115
commit 2d39957070

View File

@ -297,6 +297,8 @@ def screenshot(self):
@worker_ready.connect
def at_start(sender, **k):
logger.info("Worker is ready")
# create screenshot
if not os.path.isfile(SCREENSHOT_FILE):
logger.info("Init screenshot file")
with sender.app.connection() as conn:
@ -304,6 +306,12 @@ def at_start(sender, **k):
else:
logger.info("Screenshot file already exists")
# cancel running tasks
from agenda_culturel.models import BatchImportation
logger.info("Cancel running importation tasks")
running_tasks = BatchImportation.objects.filter(status=BatchImportation.STATUS.RUNNING).update(status=BatchImportation.STATUS.CANCELED)
@app.task(bind=True)
def run_all_recurrent_imports(self, only_fb=False):