MCPcopy Create free account
hub / github.com/StackStorm/st2 / db_func_with_retry

Function db_func_with_retry

st2common/st2common/persistence/db_init.py:43–58  ·  view source on GitHub ↗

This method is a generic retry function to support database setup and cleanup.

(db_func, *args, **kwargs)

Source from the content-addressed store, hash-verified

41
42
43def db_func_with_retry(db_func, *args, **kwargs):
44 """
45 This method is a generic retry function to support database setup and cleanup.
46 """
47 # Using as an annotation would be nice but annotations are evaluated at import
48 # time and simple ways to use the annotation means the config gets read before
49 # it is setup. Likely there is a way to use some proxies to delay the actual
50 # reading of config values however this is lesser code.
51 retrying_obj = retrying.Retrying(
52 retry_on_exception=_retry_if_connection_error,
53 wait_exponential_multiplier=cfg.CONF.database.connection_retry_backoff_mul
54 * 1000,
55 wait_exponential_max=cfg.CONF.database.connection_retry_backoff_max_s * 1000,
56 stop_max_delay=cfg.CONF.database.connection_retry_max_delay_m * 60 * 1000,
57 )
58 return retrying_obj.call(db_func, *args, **kwargs)
59
60
61def db_setup_with_retry(

Callers 2

db_cleanup_with_retryFunction · 0.90
db_setup_with_retryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected