def warn_deprecated(description=None, deprecation=None, removal=None, alternative=None): ctx = {'description': description, 'deprecation': deprecation, 'removal': removal, 'alternative': alternative} if deprecation is not None: w = CPendingDeprecationWarning(PENDING_DEPRECATION_FMT.format(**ctx)) else: w = CDeprecationWarning(DEPRECATION_FMT.format(**ctx)) warnings.warn(w)
def warn(description=None, deprecation=None, removal=None, alternative=None, stacklevel=2): """Warn of (pending) deprecation.""" ctx = {'description': description, 'deprecation': deprecation, 'removal': removal, 'alternative': alternative} if deprecation is not None: w = CPendingDeprecationWarning(PENDING_DEPRECATION_FMT.format(**ctx)) else: w = CDeprecationWarning(DEPRECATION_FMT.format(**ctx)) warnings.warn(w, stacklevel=stacklevel)
def warn_deprecated(description=None, deprecation=None, removal=None, alternative=None): ctx = { "description": description, "deprecation": deprecation, "removal": removal, "alternative": alternative } if deprecation is not None: w = CPendingDeprecationWarning(PENDING_DEPRECATION_FMT % ctx) else: w = CDeprecationWarning(DEPRECATION_FMT % ctx) warnings.warn(w)
def ensure_connected(self, conn): # Callback called for each retry while the connection # can't be established. def _error_handler(exc, interval, next_step=CONNECTION_RETRY_STEP): if getattr(conn, 'alt', None) and interval == 0: next_step = CONNECTION_FAILOVER next_step = next_step.format( when=humanize_seconds(interval, 'in', ' '), retries=int(interval / 2), max_retries=self.app.conf.broker_connection_max_retries) error(CONNECTION_ERROR, conn.as_uri(), exc, next_step) # Remember that the connection is lazy, it won't establish # until needed. # If broker_connection_retry_on_startup is not set, revert to broker_connection_retry # to determine whether connection retries are disabled. # TODO: Rely only on broker_connection_retry_on_startup to determine whether connection retries are disabled. # We will make the switch in Celery 6.0. if self.app.conf.broker_connection_retry_on_startup is None: warnings.warn( CPendingDeprecationWarning( f"The broker_connection_retry configuration setting will no longer determine\n" f"whether broker connection retries are made during startup in Celery 6.0 and above.\n" f"If you wish to retain the existing behavior for retrying connections on startup,\n" f"you should set broker_connection_retry_on_startup to {self.app.conf.broker_connection_retry}." )) if not self.app.conf.broker_connection_retry and not self.app.conf.broker_connection_retry_on_startup: # Retry disabled, just call connect directly. conn.connect() return conn conn = conn.ensure_connection( _error_handler, self.app.conf.broker_connection_max_retries, callback=maybe_shutdown, ) return conn