From 696d9d4dc1c35bff2beafd6ccc454c7ea1ba7cc6 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Wed, 10 Aug 2022 21:27:41 +0200 Subject: [PATCH] [#305]: `extend_task_props_callback` relocated. `extend_task_props_callback` moved from `_get_extended_properties` to `_store_result`. Suggested by @AllesVeldman. `extend_task_props_callback` will get the `request` object as first parameter and a copy of `task_props` (avoiding potential manipulation of the original `task_props`) as second paramenter. --- Resolves celery/django-celery-results#305 Fixes celery/django-celery-results#314 --- django_celery_results/backends/database.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/django_celery_results/backends/database.py b/django_celery_results/backends/database.py index d9348b49..1d5db1e7 100644 --- a/django_celery_results/backends/database.py +++ b/django_celery_results/backends/database.py @@ -79,10 +79,6 @@ def _get_extended_properties(self, request, traceback): # task protocol 1 task_kwargs = getattr(request, 'kwargs', None) - # TODO: We assuming that task protocol 1 could be always in use. :/ - extended_props.update( - extend_task_props_callback(getattr(request, 'kwargs', None))) - # Encode input arguments if task_args is not None: _, _, task_args = self.encode_content(task_args) @@ -133,6 +129,9 @@ def _store_result( self._get_extended_properties(request, traceback) ) + task_props.update( + extend_task_props_callback(request, dict(task_props))) + self.TaskModel._default_manager.store_result(**task_props) return result