Skip to content

Commit 3786ee2

Browse files
committed
Celery: use an internal namespace to store build task's data
Use a `Task.data` (`readthedocs.projects.task.builds.TaskData` object) to store all the data the task needs to work instead of storing it directly using `self.`. This is to allow us a simpler way to perform a clean _before_ (and/or _after_) starting the execution of a new task and avoid potentially sharing state with a previous task executed that may not be able to perform the cleanup. The only thing we need to keep in mind is that when modifying these Celery tasks, we _always_ have to add any new value inside the `self.data.<my-new-attribute>` and not directly `self.<my-new-attribute>` to avoid this problem. In the future, we could implement this protection at a code level if we want to avoid this mistake. See #8815 (comment) See https://docs.celeryproject.org/en/master/userguide/tasks.html#instantiation
1 parent 1e9c724 commit 3786ee2

File tree

2 files changed

+210
-202
lines changed

2 files changed

+210
-202
lines changed

0 commit comments

Comments
 (0)