diff options
| author | Dennis Fink | 2026-11-12 23:34:46 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-12 23:37:08 +0100 |
| commit | 52fc66cb5ff19bf0def001ae50acc1b465a0b977 (patch) | |
| tree | e791fa3e6d9f9b1b6fdf697f821adc84d2a57f0b /webmentions_ssg/tasks/consumer.py | |
| parent | b439de2005b70ec3867d589d1f4c63b83441e620 (diff) | |
| download | webmentions-ssg-52fc66cb5ff19bf0def001ae50acc1b465a0b977.tar.gz webmentions-ssg-52fc66cb5ff19bf0def001ae50acc1b465a0b977.zip | |
fix(core): decouple task imports from app initialization
Keep stable lazy task handles that register against the active Huey
backend so modules can be imported before app creation and survive
backend reinitialization.
Separate package metadata and the shared blueprint from application
startup to remove import-order dependencies and keep build-time version
lookup lightweight.
Diffstat (limited to 'webmentions_ssg/tasks/consumer.py')
| -rw-r--r-- | webmentions_ssg/tasks/consumer.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/webmentions_ssg/tasks/consumer.py b/webmentions_ssg/tasks/consumer.py index 047c010..474e775 100644 --- a/webmentions_ssg/tasks/consumer.py +++ b/webmentions_ssg/tasks/consumer.py @@ -6,45 +6,40 @@ from huey import Huey, crontab -from .. import create_app, extensions +from .. import create_app +from ..extensions import huey as queue +from . import notifications, receiver, retention, scanner def create_consumer() -> Huey: """Create and configure the Huey consumer. - The application is initialized, task modules are imported to register their - tasks, and periodic scanner, notification and verification recovery tasks - are registered. + The application is initialized and the periodic scanner, notification, + verification recovery and retention tasks are registered. :return: Configured Huey instance. """ app = create_app() - from . import notifications, receiver, retention, scanner - schedule = crontab(*app.config["SCANNER_SCHEDULE"].split(), strict=True) - extensions.huey.periodic_task(schedule)(scanner.scan_sources) + queue.periodic_task(schedule)(scanner.scan_sources) recovery_schedule = crontab( *app.config["VERIFICATION_REAPER_SCHEDULE"].split(), strict=True ) - extensions.huey.periodic_task(recovery_schedule)(receiver.recover_stale_webmentions) + queue.periodic_task(recovery_schedule)(receiver.recover_stale_webmentions) notification_schedule = crontab( *app.config["NOTIFICATION_SCHEDULE"].split(), strict=True ) - extensions.huey.periodic_task(notification_schedule)( - notifications.send_webmention_digest - ) + queue.periodic_task(notification_schedule)(notifications.send_webmention_digest) retention_schedule = crontab( *app.config["RECEIVED_RETENTION_SCHEDULE"].split(), strict=True ) - extensions.huey.periodic_task(retention_schedule)( - retention.purge_old_received_webmentions - ) + queue.periodic_task(retention_schedule)(retention.purge_old_received_webmentions) - return extensions.huey.huey + return queue.huey huey = create_consumer() |
