This method is a generic retry function to support database setup and cleanup.
(db_func, *args, **kwargs)
| 41 | |
| 42 | |
| 43 | def 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 | |
| 61 | def db_setup_with_retry( |
no outgoing calls
no test coverage detected