Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply hot-fix for Celery v4 compatibility
Flower throws a stack trace and returns HTTP 500 when the /tasks endpoint is being triggered. A defect that manifested after Celery went from v3 to v4. The following change is incorporated celery/celery#3950 To address the following issue: mher/flower#648
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
diff --git a/events/state.py b/events/state.py | ||
index effdaa6..c761e77 100644 | ||
--- a/events/state.py | ||
+++ b/events/state.py | ||
@@ -296,7 +296,7 @@ class Task(object): | ||
self.children = WeakSet( | ||
self.cluster_state.tasks.get(task_id) | ||
for task_id in children or () | ||
- if task_id in self.cluster_state.tasks | ||
+ if self.cluster_state is not None and task_id in self.cluster_state.tasks | ||
) | ||
self._serializer_handlers = { | ||
'children': self._serializable_children, | ||
@@ -384,11 +384,19 @@ class Task(object): | ||
|
||
@cached_property | ||
def parent(self): | ||
- return self.parent_id and self.cluster_state.tasks[self.parent_id] | ||
+ # issue github.com/mher/flower/issues/648 | ||
+ try: | ||
+ return self.parent_id and self.cluster_state.tasks[self.parent_id] | ||
+ except KeyError: | ||
+ return None | ||
|
||
@cached_property | ||
def root(self): | ||
- return self.root_id and self.cluster_state.tasks[self.root_id] | ||
+ # issue github.com/mher/flower/issues/648 | ||
+ try: | ||
+ return self.root_id and self.cluster_state.tasks[self.root_id] | ||
+ except KeyError: | ||
+ return None | ||
|
||
|
||
class State(object): |