Skip to main content

Settings

Celery settings object.

Attributes

AttributeTypeDescription
deprecated_settingsiterable = nullA collection of legacy configuration keys used to trigger deprecation warnings during application initialization.
broker_read_urlstringThe connection URL used for consuming messages from the broker, prioritized from environment variables or specific read-only configurations.
broker_write_urlstringThe connection URL used for sending messages to the broker, falling back to the default broker URL if no write-specific override is provided.
broker_urlstringThe primary connection string for the message broker, resolved from the CELERY_BROKER_URL environment variable or legacy host settings.
result_backendstringThe connection URI for the result store backend used to persist task states and return values.
task_default_exchangestringThe name of the default message exchange to use when no specific exchange is defined for a task.
task_default_routing_keystringThe default routing key used to bind queues and route messages when a specific key is not provided.
timezonestringThe configured time zone for task scheduling and datetime operations, supporting both Celery and Django-style configuration keys.

Constructor

Signature

def Settings(
*args: any,
deprecated_settings: iterable = None,
**kwargs: any
)

Parameters

NameTypeDescription
*argsanyVariable length argument list passed to the parent class constructor.
deprecated_settingsiterable = NoneAn optional collection of settings that are marked as deprecated.
**kwargsanyArbitrary keyword arguments passed to the parent class constructor.

Signature

def Settings(
*args: any,
deprecated_settings: list = None,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*argsanyPositional arguments passed to the parent ConfigurationView class
deprecated_settingslist = NoneA list of setting keys that have been deprecated and should trigger warnings
**kwargsanyKeyword arguments passed to the parent ConfigurationView class

Methods


broker_read_url()

@classmethod
def broker_read_url() - > string

Retrieves the URL used for reading from the message broker, falling back to the default broker URL if not explicitly set.

Returns

TypeDescription
stringThe connection string for the read-only broker connection

broker_write_url()

@classmethod
def broker_write_url() - > string

Retrieves the URL used for writing to the message broker, falling back to the default broker URL if not explicitly set.

Returns

TypeDescription
stringThe connection string for the write-only broker connection

broker_url()

@classmethod
def broker_url() - > string

Retrieves the primary broker connection URL from environment variables or configuration keys.

Returns

TypeDescription
stringThe primary broker connection string

result_backend()

@classmethod
def result_backend() - > string

Retrieves the configured result backend URL used for storing task results.

Returns

TypeDescription
stringThe connection string for the result storage backend

task_default_exchange()

@classmethod
def task_default_exchange() - > string

Retrieves the default exchange name for tasks, falling back to the default queue name if not specified.

Returns

TypeDescription
stringThe name of the default AMQP exchange

task_default_routing_key()

@classmethod
def task_default_routing_key() - > string

Retrieves the default routing key for tasks, falling back to the default queue name if not specified.

Returns

TypeDescription
stringThe default routing key string

timezone()

@classmethod
def timezone() - > string

Retrieves the configured timezone, supporting both Celery and Django timezone setting keys.

Returns

TypeDescription
stringThe timezone identifier string

without_defaults()

@classmethod
def without_defaults() - > [Settings](settings.md?sid=celery_app_utils_settings)

Return the current configuration, but without defaults.

Returns

TypeDescription
[Settings](settings.md?sid=celery_app_utils_settings)A new Settings object containing only user-defined configuration values

value_set_for()

@classmethod
def value_set_for(
key: string
) - > boolean

Checks if a specific configuration key has been explicitly set by the user rather than relying on a default.

Parameters

NameTypeDescription
keystringThe configuration key to check for explicit definition

Returns

TypeDescription
booleanTrue if the key is present in the user-defined configuration, False otherwise

find_option()

@classmethod
def find_option(
name: string,
namespace: string = ''
) - > tuple

Search for option by name.

Parameters

NameTypeDescription
namestringFull name of the option to search for
namespacestring = ''The preferred namespace to search within

Returns

TypeDescription
tupleA tuple of (namespace, key, type) for the found option

find_value_for_key()

@classmethod
def find_value_for_key(
name: string,
namespace: string = 'celery'
) - > any

Shortcut to get_by_parts(*find_option(name)[:-1]).

Parameters

NameTypeDescription
namestringThe name of the setting to find
namespacestring = 'celery'The namespace to use for the search

Returns

TypeDescription
anyThe value associated with the resolved configuration key

get_by_parts()

@classmethod
def get_by_parts(
*parts: string
) - > any

Return the current value for setting specified as a path.

Parameters

NameTypeDescription
*partsstringIndividual components of a setting name to be joined (e.g., 'worker', 'concurrency')

Returns

TypeDescription
anyThe value of the setting found by joining the provided parts with underscores

finalize()

@classmethod
def finalize() - > [Settings](settings.md?sid=celery_app_utils_settings)

Triggers the reading of the actual configuration by performing a dummy access, ensuring the view is fully populated.

Returns

TypeDescription
[Settings](settings.md?sid=celery_app_utils_settings)The finalized Settings instance

table()

@classmethod
def table(
with_defaults: boolean = False,
censored: boolean = True
) - > dict

Generates a dictionary of configuration settings, optionally including defaults and filtering sensitive information.

Parameters

NameTypeDescription
with_defaultsboolean = FalseWhether to include default Celery settings in the output
censoredboolean = TrueWhether to mask sensitive information like passwords and API keys

Returns

TypeDescription
dictA dictionary mapping setting names to their current values

humanize()

@classmethod
def humanize(
with_defaults: boolean = False,
censored: boolean = True
) - > string

Return a human readable text showing configuration changes.

Parameters

NameTypeDescription
with_defaultsboolean = FalseWhether to include default settings in the human-readable output
censoredboolean = TrueWhether to mask sensitive values in the output

Returns

TypeDescription
stringA formatted string containing key-value pairs of the configuration

maybe_warn_deprecated_settings()

@classmethod
def maybe_warn_deprecated_settings() - > boolean

Issues deprecation warnings for any settings identified as deprecated during initialization.

Returns

TypeDescription
booleanTrue if warnings were issued, False if no deprecated settings were found