tons of stuff but working again

This commit is contained in:
2025-07-10 02:21:19 -05:00
parent 5e828f8e74
commit 2b63f4c9c7
369 changed files with 337 additions and 472 deletions

View File

@ -1,12 +1,8 @@
# File: app/celery_app.py
import os
import json
import importlib
from celery import Celery
# 1) Create the Celery object (broker/backend will be set from our Flask config)
celery = Celery('natureinpots')
from app.celery_instance import celery
def init_celery(app):
@ -20,15 +16,18 @@ def init_celery(app):
# 2. Make all tasks run inside the Flask application context
TaskBase = celery.Task
class ContextTask(TaskBase):
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
# 3. Discover all plugins by looking for plugin.json in plugins/
plugins_dir = os.path.join(app.root_path, '..', 'plugins')
task_modules = []
for plugin_name in sorted(os.listdir(plugins_dir)):
manifest = os.path.join(plugins_dir, plugin_name, 'plugin.json')
if not os.path.isfile(manifest):
@ -76,9 +75,7 @@ def init_celery(app):
return celery
# 5) Immediately bootstrap Celery with our Flask app so that
# any `celery -A app.celery_app:celery worker --beat` invocation
# will pick up your plugins tasks and schedules.
# Immediately bootstrap Celery whenever this module is imported
from app import create_app
_flask_app = create_app()
init_celery(_flask_app)