Browse Source

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

Ask Solem 15 năm trước cách đây
mục cha
commit
c12ad5cb28
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  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