refactor dojo async task base task (bugfix branch)#14240
Open
valentijnscholten wants to merge 3 commits intoDefectDojo:bugfixfrom
Open
refactor dojo async task base task (bugfix branch)#14240valentijnscholten wants to merge 3 commits intoDefectDojo:bugfixfrom
valentijnscholten wants to merge 3 commits intoDefectDojo:bugfixfrom
Conversation
The custom decorators that we have on Celery tasks interfere with some (advanced) celery functionality like signatures. This PR refactors this to have a clean base task that passes on context, but does not interfere with celery mechanisms. The logic to decide whether or not the task is to be called asynchronously is now in a dispatch method.
2a17750 to
d2d0bdc
Compare
- Use class reference instead of self for task dispatch (self.method returns bound method without .si() attribute) - Update location_manager.py to use dojo_dispatch_task instead of @dojo_async_task decorator - Convert task methods to static-like functions (no self parameter)
- Avoid passing manager/task attributes via instance (use class task objects to ensure .si() is available) - Stop dispatching non-task jira_helper.push_to_jira through dojo_dispatch_task; call it directly and let it dispatch the underlying celery tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR ports the async task refactor changes from #13986 to the bugfix branch.
The custom decorators that we have on Celery tasks interfere with some (advanced) celery functionality like signatures. This PR refactors this to have a clean base task that passes on context, but does not interfere with celery mechanisms.
The logic to decide whether or not the task is to be called asynchronously is now in a dispatch method.
Key Changes:
@dojo_async_taskdecorator patterndojo_dispatch_taskfunction for dispatching Celery tasksPgHistoryTask) that preserves pghistory contextPro needs similar changes via DefectDojo-Inc/dojo-pro#2124