Browse Source

Merge pull request #2775 from celery/ionelmc-fix-maybe_unroll_group

Fixed maybe_unroll_group to return the task when it is not a group
Omer Katz 9 years ago
parent
commit
2dda8b7c23
2 changed files with 11 additions and 6 deletions
  1. 2 2
      celery/canvas.py
  2. 9 4
      celery/tests/case.py

+ 2 - 2
celery/canvas.py

@@ -93,7 +93,7 @@ def maybe_unroll_group(g):
         try:
             size = g.tasks.__length_hint__()
         except (AttributeError, TypeError):
-            pass
+            return g
         else:
             return list(g.tasks)[0] if size == 1 else g
     else:
@@ -607,7 +607,7 @@ def _maybe_group(tasks):
     elif isinstance(tasks, Signature):
         tasks = [tasks]
     else:
-        tasks = map(signature, regen(tasks))
+        tasks = [signature(t) for t in regen(tasks)]
     return tasks
 
 

+ 9 - 4
celery/tests/case.py

@@ -232,10 +232,15 @@ def _is_magic_module(m):
     # will load _tkinter and other shit when touched.
 
     # pyflakes refuses to accept 'noqa' for this isinstance.
-    cls, modtype = m.__class__, types.ModuleType
-    return (cls is not modtype and (
-        '__getattr__' in vars(m.__class__) or
-        '__getattribute__' in vars(m.__class__)))
+    cls, modtype = type(m), types.ModuleType
+    try:
+        variables = vars(cls)
+    except TypeError:
+        return True
+    else:
+        return (cls is not modtype and (
+            '__getattr__' in variables or
+            '__getattribute__' in variables))
 
 
 class _AssertWarnsContext(_AssertRaisesBaseContext):