| 361 | |
| 362 | @classmethod |
| 363 | def bind(cls, app): |
| 364 | was_bound, cls.__bound__ = cls.__bound__, True |
| 365 | cls._app = app |
| 366 | conf = app.conf |
| 367 | cls._exec_options = None # clear option cache |
| 368 | |
| 369 | if cls.typing is None: |
| 370 | cls.typing = app.strict_typing |
| 371 | |
| 372 | for attr_name, config_name in cls.from_config: |
| 373 | if getattr(cls, attr_name, None) is None: |
| 374 | setattr(cls, attr_name, conf[config_name]) |
| 375 | |
| 376 | # decorate with annotations from config. |
| 377 | if not was_bound: |
| 378 | cls.annotate() |
| 379 | |
| 380 | from celery.utils.threads import LocalStack |
| 381 | cls.request_stack = LocalStack() |
| 382 | |
| 383 | # PeriodicTask uses this to add itself to the PeriodicTask schedule. |
| 384 | cls.on_bound(app) |
| 385 | |
| 386 | return app |
| 387 | |
| 388 | @classmethod |
| 389 | def on_bound(cls, app): |