Repository URL to install this package:
Version:
3.4.36 ▾
|
ó xEYc @ s d Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l Z d d l m Z d d l m Z d d l m Z e j e Z d Z d Z d Z d e f d YZ d e f d YZ d S( s ================================= Multiple DB API backend support. ================================= A DB backend module should implement a method named 'get_backend' which takes no arguments. The method can return any object that implements DB API methods. iÿÿÿÿN( t removals( t excutils( t importutils( t reflection( t _LE( t exception( t optionsc C s t | j d <| S( sÄ Indicate api method as safe for re-connection to database. Database connection retries will be enabled for the decorated api method. Database connection failure can have many causes, which can be temporary. In such cases retry may increase the likelihood of connection. Usage:: @safe_for_db_retry def api_method(self): self.engine.connect() :param f: database api method. :type f: function. t enable_retry_on_disconnect( t Truet __dict__( t f( ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt safe_for_db_retry, s c C s t | j d <| S( s Retry a DB API call if Deadlock was received. wrap_db_entry will be applied to all db.api functions marked with this decorator. t enable_retry_on_deadlock( R R ( R ( ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt retry_on_deadlockA s c C s t | j d <| S( s Retry a DB API call if RetryRequest exception was received. wrap_db_entry will be applied to all db.api functions marked with this decorator. t enable_retry_on_request( R R ( R ( ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt retry_on_requestK s t wrap_db_retryc B sV e Z d Z e j d d d d e d e e e d d Z d Z d Z RS( s Retry db.api methods, if db_error raised Retry decorated db.api methods. This decorator catches db_error and retries function in a loop until it succeeds, or until maximum retries count will be reached. Keyword arguments: :param retry_interval: seconds between transaction retries :type retry_interval: int or float :param max_retries: max number of retries before an error is raised :type max_retries: int :param inc_retry_interval: determine increase retry interval or not :type inc_retry_interval: bool :param max_retry_interval: max interval value between retries :type max_retry_interval: int or float :param exception_checker: checks if an exception should trigger a retry :type exception_checker: callable R s" Retry on request is always enabledi i i c C s t S( N( t False( t exc( ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt <lambda>t s c C s t t | j t j f | _ | | _ | rI | j t j f 7_ n | rg | j t j f 7_ n | | _ | | _ | | _ | | _ d S( N( t superR t __init__R t RetryRequestt db_errort exception_checkert DBConnectionErrort DBDeadlockt retry_intervalt max_retriest inc_retry_intervalt max_retry_interval( t selfR R R R t retry_on_disconnectR R R ( ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyR n s c s% t j f d } | S( Nc s( j } j } xt r#y | | SWq t k r} t j ~ } j | } | d k ru | | _ nO | r t j t d n t | t j rÄ t | j | _ | j | _ n Wd QXt j d t j t j | j rt | d j } n | d 8} q Xq Wd S( Ni s DB exceeded retry limit.s# Performing DB retry for function %si i ( R R R t ExceptionR t save_and_reraise_exceptiont _is_exception_expectedt reraiset LOGR R t isinstanceR t typet inner_exct type_t valuet debugR t get_callable_namet timet sleepR t minR ( t argst kwargst next_intervalt remainingt et ectxtt expected( R R ( s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt wrapper s. ( t sixt wraps( R R R7 ( ( R R s@ /home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt __call__ s !!c C sH t | | j r; t | t j s7 t j d | n t S| j | S( Ns DB error: %s( R&