def init_app(self, app):
_state._register_app = self.original_register_app  <EOL>if not hasattr(app, '<STR_LIT>'):<EOL><INDENT>app.extensions = dict()<EOL><DEDENT>if '<STR_LIT>' in app.extensions:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>app.extensions['<STR_LIT>'] = _CeleryState(self, app)<EOL>super(Celery, self).__init__(app.import_name, broker=app.config['<STR_LIT>'])<EOL>if '<STR_LIT>' in app.config:<EOL><INDENT>self._preconf['<STR_LIT>'] = app.config['<STR_LIT>']<EOL><DEDENT>self.conf.update(app.config)<EOL>task_base = self.Task<EOL>class ContextTask(task_base):<EOL><INDENT>def __call__(self, *_args, **_kwargs):<EOL><INDENT>with app.app_context():<EOL><INDENT>return task_base.__call__(self, *_args, **_kwargs)<EOL><DEDENT><DEDENT><DEDENT>setattr(ContextTask, '<STR_LIT>', True)<EOL>setattr(self, '<STR_LIT>', ContextTask)<EOL>
Actual method to read celery settings from app configuration and initialize the celery instance.

        :param app: Flask application instance.