Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
x“EYc@sdZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlmZddl
mZdd	l
mZejeƒZd
„Zd„Zd„Zd
efd„ƒYZdefd„ƒYZdS(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(tremovals(texcutils(timportutils(t
reflection(t_LE(t	exception(toptionscCst|jd<|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.
    tenable_retry_on_disconnect(tTruet__dict__(tf((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pytsafe_for_db_retry,s
cCst|jd<|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.
    tenable_retry_on_deadlock(RR	(R
((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pytretry_on_deadlockAs
cCst|jd<|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.
    tenable_retry_on_request(RR	(R
((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pytretry_on_requestKs
t
wrap_db_retryc
BsVeZdZejddƒddedeeed„d„ƒZd„Zd	„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
    Rs"Retry on request is always enablediii
cCstS(N(tFalse(texc((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt<lambda>tsc		Cstt|ƒjƒtjf|_||_|rI|jtjf7_n|rg|jtjf7_n||_	||_
||_||_dS(N(
tsuperRt__init__RtRetryRequesttdb_errortexception_checkertDBConnectionErrort
DBDeadlocktretry_intervaltmax_retriestinc_retry_intervaltmax_retry_interval(	tselfRRRRtretry_on_disconnectR
RR((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyRns				cs%tjˆƒ‡‡fd†ƒ}|S(Ncs(ˆj}ˆj}xtr#yˆ||ŽSWqtk
r}tjƒ~}ˆj|ƒ}|dkru||_nO|r‘tj	t
dƒƒnt|t	jƒrÄt
|jƒ|_|j|_nWdQXtjdtjˆƒƒtj|ƒˆjrt|dˆjƒ}n|d8}qXqWdS(NisDB exceeded retry limit.s#Performing DB retry for function %sii(RRRt	ExceptionRtsave_and_reraise_exceptiont_is_exception_expectedtreraisetLOGRRt
isinstanceRttypet	inner_excttype_tvaluetdebugRtget_callable_namettimetsleepRtminR(targstkwargst
next_intervalt	remainingtetectxttexpected(R
R(s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pytwrapper„s.			
	
	(tsixtwraps(RR
R7((R
Rs@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt__call__ƒs!!cCsHt||jƒr;t|tjƒs7tjd|ƒntS|j|ƒS(NsDB error: %s(R&RRRR%R+RR(RR((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyR#§s
(
t__name__t
__module__t__doc__Rt
removed_kwargRRRR:R#(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyRUs		$tDBAPIcBsDeZdZded„Zd„Zd„Zeded„ƒZ	RS(s2Initialize the chosen DB API backend.

    After initialization API methods is available as normal attributes of
    ``DBAPI`` subclass. Database API methods are supposed to be called as
    DBAPI instance methods.

    :param backend_name: name of the backend to load
    :type backend_name: str

    :param backend_mapping: backend name -> module/class to load mapping
    :type backend_mapping: dict
    :default backend_mapping: None

    :param lazy: load the DB backend lazily on the first DB API method call
    :type lazy: bool
    :default lazy: False

    :keyword use_db_reconnect: retry DB transactions on disconnect or not
    :type use_db_reconnect: bool

    :keyword retry_interval: seconds between transaction retries
    :type retry_interval: int

    :keyword inc_retry_interval: increase retry interval or not
    :type inc_retry_interval: bool

    :keyword max_retry_interval: max interval value between retries
    :type max_retry_interval: int

    :keyword max_retries: max number of retries before an error is raised
    :type max_retries: int
    cKsud|_||_|pi|_tjƒ|_|sC|jƒn|jdt	ƒ|_
d„|jƒDƒ|_dS(Ntuse_db_reconnectcSs+i|]!\}}|dkr||“qS(RRRR(sretry_intervalsinc_retry_intervalsmax_retry_intervalsmax_retries((t.0tktv((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pys
<dictcomp>às
		(
tNonet_backendt
_backend_namet_backend_mappingt	threadingtLockt_lockt
_load_backendtgetRR@titemst_wrap_db_kwargs(Rtbackend_nametbackend_mappingtlazyR1((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyRÔs		
c	Csz|jk|jsp|jj|j|jƒ}tjdi|jd6|d6ƒtj|ƒ}|j	ƒ|_nWdQXdS(Ns&Loading backend %(name)r from %(path)rtnametpath(
RJRERGRLRFR%R+Rt
import_moduletget_backend(Rtbackend_pathtbackend_mod((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyRKæs
		
c	Cs½|js|jƒnt|j|ƒ}t|dƒs;|S|joV|jjdtƒ}|jjdtƒ}|jjdtƒ}|s•|s•|r¹td|d||j	|ƒ}n|S(NR:RRRR R
(
RERKtgetattrthasattrR@R	RLRRRN(RtkeytattrR R
R((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt__getattr__òs 	
	cCsn|jtjdƒ|d|jjd|d|d|jjd|jjd|jjd|jjd	|jj	ƒS(
syInitialize DBAPI instance given a config instance.

        :param conf: oslo.config config instance
        :type conf: oslo.config.cfg.ConfigOpts

        :param backend_mapping: backend name -> module/class to load mapping
        :type backend_mapping: dict

        :param lazy: load the DB backend lazily on the first DB API method call
        :type lazy: bool

        tdatabaseRORPRQR@RRRR(
t
register_optsRt
database_optsR]tbackendR@tdb_retry_intervaltdb_inc_retry_intervaltdb_max_retry_intervaltdb_max_retries(tclstconfRPRQ((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pytfrom_config
sN(
R;R<R=RDRRRKR\tclassmethodRg(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyR?²s 		(R=tloggingRHR-t
debtcollectorRt
oslo_utilsRRRR8t
oslo_db._i18nRtoslo_dbRRt	getLoggerR;R%RR
RtobjectRR?(((s@/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_db/api.pyt<module>s"		
	
]