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

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
Changes
=======

Version 2.1.0 (released 2025-04-28)

- ext: add celery signals entrypoint

Version 2.0.0 (released 2024-12-02)

- setup: bump invenio dependencies
Expand Down
2 changes: 1 addition & 1 deletion invenio_celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ def sum(x, y):

from .ext import InvenioCelery

__version__ = "2.0.0"
__version__ = "2.1.0"

__all__ = ("__version__", "InvenioCelery")
7 changes: 7 additions & 0 deletions invenio_celery/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ def init_app(self, app, entry_point_group="invenio_celery.tasks", **kwargs):
self.init_config(app)
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
Contributor 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
1 change: 1 addition & 0 deletions tests/test_invenio_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def _mock_entry_points(group, name=None):
EntryPoint("bpackage_2", "bpackage.second_tasks"),
EntryPoint("apackage", "apackage.third_tasks"),
],
"invenio_celery.signals": [],
}
assert name is None
for entry_point in data[group]:
Expand Down