MCPcopy Create free account
hub / github.com/celery/celery / bind

Method bind

celery/app/task.py:459–506  ·  view source on GitHub ↗
(cls, app)

Source from the content-addressed store, hash-verified

457
458 @classmethod
459 def bind(cls, app):
460 was_bound, cls.__bound__ = cls.__bound__, True
461 cls._app = app
462 conf = app.conf
463 cls._exec_options = None # clear option cache
464
465 if not was_bound:
466 for attr in ('queue', 'exchange', 'exchange_type',
467 'routing_key', 'delivery_mode', 'priority'):
468 if attr in cls.__dict__:
469 # In Celery 6.0, make these task attributes have no effect
470 deprecated.warn(
471 description=f'The {attr!r} task attribute',
472 removal='6.0',
473 alternative='Use the task_routes setting instead.',
474 )
475
476 if cls.typing is None:
477 cls.typing = app.strict_typing
478
479 for attr_name, config_name in cls.from_config:
480 if getattr(cls, attr_name, None) is None:
481 setattr(cls, attr_name, conf[config_name])
482
483 if cls.acks_on_failure is None:
484 cls.acks_on_failure = (
485 cls.acks_on_failure_or_timeout
486 if cls.acks_on_failure_or_timeout is not None
487 else True
488 )
489 if cls.acks_on_timeout is None:
490 cls.acks_on_timeout = (
491 cls.acks_on_failure_or_timeout
492 if cls.acks_on_failure_or_timeout is not None
493 else True
494 )
495
496 # decorate with annotations from config.
497 if not was_bound:
498 cls.annotate()
499
500 from celery.utils.threads import LocalStack
501 cls.request_stack = LocalStack()
502
503 # PeriodicTask uses this to add itself to the PeriodicTask schedule.
504 cls.on_bound(app)
505
506 return app
507
508 @classmethod
509 def on_bound(cls, app):

Callers 12

__init__Method · 0.80
get_avail_portMethod · 0.80
_get_appMethod · 0.80
wrapperFunction · 0.80
dump_argumentsFunction · 0.80
_task_from_funMethod · 0.80
register_taskMethod · 0.80
finalizeMethod · 0.80

Calls 3

warnMethod · 0.80
on_boundMethod · 0.80
annotateMethod · 0.45