diff --git a/django_celery_results/backends/database.py b/django_celery_results/backends/database.py index 1d5db1e7..bb921500 100644 --- a/django_celery_results/backends/database.py +++ b/django_celery_results/backends/database.py @@ -129,6 +129,8 @@ def _store_result( self._get_extended_properties(request, traceback) ) + # TODO: Wrap this and make some sanity checks to complain the Mapping + # protocol. task_props.update( extend_task_props_callback(request, dict(task_props))) diff --git a/django_celery_results/settings.py b/django_celery_results/settings.py index 5f4eb61d..a9889a13 100644 --- a/django_celery_results/settings.py +++ b/django_celery_results/settings.py @@ -1,16 +1,19 @@ from django.conf import settings +from django.core.exceptions import ImproperlyConfigured def get_callback_function(settings_name, default=None): """Return the callback function for the given settings name.""" callback = getattr(settings, settings_name, None) - if callback is None: + if not callback: return default - if callable(callback): - return callback + if not callable(callback): + raise ImproperlyConfigured(f"{settings_name} must be callable.") + + return callback extend_task_props_callback = get_callback_function( - "CELERY_RESULTS_EXTEND_TASK_PROPS_CALLBACK" + "CELERY_RESULTS_EXTEND_TASK_PROPS_CALLBACK", dict ) \ No newline at end of file