Skip to content

Commit

Permalink
[celery#305]: extend_task_props_callback relocated.
Browse files Browse the repository at this point in the history
`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#305

Fixes celery#314
  • Loading branch information
diegocastrum committed Aug 17, 2022
1 parent 50174d1 commit e064403
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions django_celery_results/backends/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e064403

Please sign in to comment.