#NEWLINE# def init_app( self , app ) : #NEWLINE# #INDENT# 'Actual method to read celery settings from app configuration and initialize the celery instance.\n\n        Positional arguments:\n        app -- Flask application instance.\n        ' #NEWLINE# _state . _register_app = self . original_register_app #NEWLINE# if ( not hasattr ( app , 'extensions' ) ) : #NEWLINE# #INDENT# app . extensions = dict ( ) #NEWLINE# #UNINDENT# if ( 'celery' in app . extensions ) : #NEWLINE# #INDENT# raise ValueError ( 'Already registered extension CELERY.' ) #NEWLINE# #UNINDENT# app . extensions [ 'celery' ] = _CeleryState ( self , app ) #NEWLINE# super ( Celery , self ) . __init__ ( app . import_name , broker = app . config [ 'CELERY_BROKER_URL' ] ) #NEWLINE# if ( 'CELERY_RESULT_BACKEND' in app . config ) : #NEWLINE# #INDENT# self . _preconf [ 'CELERY_RESULT_BACKEND' ] = app . config [ 'CELERY_RESULT_BACKEND' ] #NEWLINE# #UNINDENT# self . conf . update ( app . config ) #NEWLINE# task_base = self . Task #NEWLINE# class ContextTask ( task_base ) : #NEWLINE# #INDENT# 'Celery instance wrapped within the Flask app context.' #NEWLINE# def __call__( self , * _args , **_kwargs ) : #NEWLINE# #INDENT# with app . app_context ( ) : #NEWLINE# #INDENT# return task_base . __call__ ( self , * _args , ** _kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# setattr ( ContextTask , 'abstract' , True ) #NEWLINE# setattr ( self , 'Task' , ContextTask )