Browse Source

Fixes celery graph on Python3. Closes #2133

Ask Solem 9 years ago
parent
commit
2a47f425c7
2 changed files with 7 additions and 3 deletions
  1. 3 1
      celery/bootsteps.py
  2. 4 2
      celery/datastructures.py

+ 3 - 1
celery/bootsteps.py

@@ -13,6 +13,7 @@ from threading import Event
 
 from kombu.common import ignore_errors
 from kombu.utils import symbol_by_name
+from kombu.utils.encoding import bytes_to_str
 
 from .datastructures import DependencyGraph, GraphFormatter
 from .five import values, with_metaclass
@@ -58,7 +59,8 @@ class StepFormatter(GraphFormatter):
     def label(self, step):
         return step and '{0}{1}'.format(
             self._get_prefix(step),
-            (step.label or _label(step)).encode('utf-8', 'ignore'),
+            bytes_to_str(
+                (step.label or _label(step)).encode('utf-8', 'ignore')),
         )
 
     def _get_prefix(self, step):

+ 4 - 2
celery/datastructures.py

@@ -17,7 +17,7 @@ from functools import partial
 from itertools import chain
 
 from billiard.einfo import ExceptionInfo  # noqa
-from kombu.utils.encoding import safe_str
+from kombu.utils.encoding import safe_str, bytes_to_str
 from kombu.utils.limits import TokenBucket  # noqa
 
 from celery.five import items
@@ -288,7 +288,9 @@ class DependencyGraph(object):
         """
         seen = set()
         draw = formatter or self.formatter
-        P = partial(print, file=fh)
+
+        def P(s):
+            print(bytes_to_str(s), file=fh)
 
         def if_not_seen(fun, obj):
             if draw.label(obj) not in seen: