Skip to content

ext: add celery signals ep #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions invenio_celery/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ def __init__(self, app=None, **kwargs):
def init_app(self, app, entry_point_group="invenio_celery.tasks", **kwargs):
"""Initialize application object."""
self.init_config(app)
app.logger.setLevel("DEBUG")
Copy link
Preview

Copilot AI Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Setting the logger level to DEBUG directly here might override the application's logging configuration unexpectedly. Consider conditionally setting the logging level for development or making this configurable.

Suggested change
app.logger.setLevel("DEBUG")
log_level = app.config.get("LOG_LEVEL", "WARNING")
app.logger.setLevel(log_level)

Copilot uses AI. Check for mistakes.

self.celery = FlaskCeleryExt(app).celery
self.entry_point_group = entry_point_group
self.load_celery_signals()
app.extensions["invenio-celery"] = self

def load_celery_signals(self):
"""Load Celery signals."""
# Import Celery signals via entry points
for ep in pkg_resources.iter_entry_points("invenio_celery.signals"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addded this to have a common place where the signals are registered, it could also be done in each repo if we prefer - instead of using an entry point

__import__(ep.module_name) # Just import the module to trigger registration

def load_entry_points(self):
"""Load tasks from entry points."""
if self.entry_point_group:
Expand Down