Connection
Service managing the consumer broker connection.
Attributes
| Attribute | Type | Description |
|---|---|---|
| connection | kombu.Connection = null | The active consumer broker connection instance managed by this service, initialized to None and populated during the start step. |
Constructor
Signature
def Connection(
c: Any,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| c | Any | The consumer instance or context object being initialized. |
| **kwargs | dict | Additional keyword arguments passed to the parent StartStopStep class. |
Signature
def Connection(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer),
kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance that this service is attached to |
| kwargs | dict | Additional keyword arguments passed to the parent StartStopStep class |
Methods
start()
@classmethod
def start(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer)
) - > null
Establishes the broker connection for the consumer and logs the connection URI.
Parameters
| Name | Type | Description |
|---|---|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance for which to establish a connection |
Returns
| Type | Description |
|---|---|
null | None |
close_connection()
@classmethod
def close_connection(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer)
) - > null
Close and clear c.connection.
Parameters
| Name | Type | Description |
|---|---|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance whose connection should be closed and cleared |
Returns
| Type | Description |
|---|---|
null | None |
shutdown()
@classmethod
def shutdown(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer)
) - > null
Triggers the connection closure during service shutdown to ensure the green pidbox thread exits.
Parameters
| Name | Type | Description |
|---|---|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance to shut down |
Returns
| Type | Description |
|---|---|
null | None |
info()
@classmethod
def info(
c: [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer)
) - > dict
Fetches metadata about the current broker connection, ensuring sensitive credentials like passwords are redacted.
Parameters
| Name | Type | Description |
|---|---|---|
| c | [Consumer](../consumer/consumer.md?sid=celery_worker_consumer_consumer_consumer) | The consumer instance from which to retrieve connection information |
Returns
| Type | Description |
|---|---|
dict | A dictionary containing broker connection parameters or 'N/A' if no connection exists |