Explorar o código

Add the ability to turn off automatic registration of tasks by setting Task.autoregister = False.

Ask Solem %!s(int64=15) %!d(string=hai) anos
pai
achega
c12ad5cb28
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      celery/task/base.py

+ 2 - 1
celery/task/base.py

@@ -33,7 +33,7 @@ class TaskType(type):
 
         # Abstract class, remove the abstract attribute so
         # any class inheriting from this won't be abstract by default.
-        if attrs.pop("abstract", None):
+        if attrs.pop("abstract", None) or not attrs.get("autoregister", True):
             return super_new(cls, name, bases, attrs)
 
         # Automatically generate missing name.
@@ -138,6 +138,7 @@ class Task(object):
 
     name = None
     abstract = True
+    autoregister = True
     type = "regular"
     exchange = None
     routing_key = None