|  | @@ -3,17 +3,42 @@ from __future__ import absolute_import
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  from ...utils import uuid
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#: global list of functions defining a built-in task.
 | 
	
		
			
				|  |  | +#: these are called for every app instance to setup built-in task.
 | 
	
		
			
				|  |  |  _builtins = []
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def builtin_task(constructor):
 | 
	
		
			
				|  |  | +    """Decorator that specifies that the decorated function is a function
 | 
	
		
			
				|  |  | +    that generates a built-in task.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    The function will then be called for every new app instance created
 | 
	
		
			
				|  |  | +    (lazily, so more exactly when the task registry for that app is needed).
 | 
	
		
			
				|  |  | +    """
 | 
	
		
			
				|  |  |      _builtins.append(constructor)
 | 
	
		
			
				|  |  |      return constructor
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +def load_builtins(app):
 | 
	
		
			
				|  |  | +    """Loads the built-in tasks for an app instance."""
 | 
	
		
			
				|  |  | +    for constructor in _builtins:
 | 
	
		
			
				|  |  | +        constructor(app)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  @builtin_task
 | 
	
		
			
				|  |  |  def add_backend_cleanup_task(app):
 | 
	
		
			
				|  |  | +    """The backend cleanup task can be used to clean up the default result
 | 
	
		
			
				|  |  | +    backend.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    This task is also added do the periodic task schedule so that it is
 | 
	
		
			
				|  |  | +    run every day at midnight, but :program:`celerybeat` must be running
 | 
	
		
			
				|  |  | +    for this to be effective.
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    Note that not all backends do anything for this, what needs to be
 | 
	
		
			
				|  |  | +    done at cleanup is up to each backend, and some backends
 | 
	
		
			
				|  |  | +    may even clean up in realtime so that a periodic cleanup is not necessary.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    """
 | 
	
		
			
				|  |  |      @app.task(name="celery.backend_cleanup")
 | 
	
		
			
				|  |  |      def backend_cleanup():
 | 
	
		
			
				|  |  |          app.backend.cleanup()
 | 
	
	
		
			
				|  | @@ -23,6 +48,12 @@ def add_backend_cleanup_task(app):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @builtin_task
 | 
	
		
			
				|  |  |  def add_unlock_chord_task(app):
 | 
	
		
			
				|  |  | +    """The unlock chord task is used by result backends that doesn't
 | 
	
		
			
				|  |  | +    have native chord support.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    It creates a task chain polling the header for completion.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    """
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @app.task(name="celery.chord_unlock", max_retries=None)
 | 
	
		
			
				|  |  |      def unlock_chord(setid, callback, interval=1, propagate=False,
 | 
	
	
		
			
				|  | @@ -42,6 +73,9 @@ def add_unlock_chord_task(app):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @builtin_task
 | 
	
		
			
				|  |  |  def add_chord_task(app):
 | 
	
		
			
				|  |  | +    """Every chord is executed in a dedicated task, so that the chord
 | 
	
		
			
				|  |  | +    can be used as a subtask, and this generates the task
 | 
	
		
			
				|  |  | +    responsible for that."""
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @app.task(name="celery.chord", accept_magic_kwargs=False)
 | 
	
		
			
				|  |  |      def chord(set, body, interval=1, max_retries=None,
 | 
	
	
		
			
				|  | @@ -64,7 +98,3 @@ def add_chord_task(app):
 | 
	
		
			
				|  |  |          return set.apply_async(taskset_id=setid)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return chord
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -def load_builtins(app):
 | 
	
		
			
				|  |  | -    for constructor in _builtins:
 | 
	
		
			
				|  |  | -        constructor(app)
 |