403Webshell
Server IP : 162.144.4.212  /  Your IP : 216.73.216.108
Web Server : Apache
System : Linux gator2125.hostgator.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User : cozeellc ( 2980)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/libexec/oracle-cloud-agent/plugins/osms/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/libexec/oracle-cloud-agent/plugins/osms/circuitbreaker.pyc
a

ٓ�f�(�@s8ddlmZddlmZddlmZddlmZddlmZddlmZmZddl	m
Z
mZddlm
Z
mZdd	lmZmZzdd
lmZWney�dd
lmZYn0z
efZWney�eefZYn0dZdZd
Zdd�Zdd�ZGdd�de�Z Gdd�de!�Z"Gdd�de�Z#ddddde fdd�Z$dS)�)�unicode_literals)�division)�print_function)�absolute_import)�wraps)�datetime�	timedelta)�isgeneratorfunction�isclass)�AnyStr�Iterable)�ceil�floor)�	monotonic�closed�open�	half_opencs�fdd�}|S)zOBuild a predicate function that checks if an exception is a subtype from a listcs
t|��S�N)�
issubclass)�thrown_type�_��	exc_types��r/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/circuitbreaker.py�
matches_types sz(in_exception_list.<locals>.matches_typesr)rrrrr�in_exception_listsrcCsvt|�rt|t�rt|�}nVz&t|�t|t�r8td��t|�}Wn.typt	|�r`t|�rhtd��|}Yn0|S)az Build a failure predicate_function.
          The returned function has the signature (Type[Exception], Exception) -> bool.
          Return value True indicates a failure in the underlying function.

        :param expected_exception: either an type of Exception, iterable of Exception types, or a predicate function.

          If an Exception type or iterable of Exception types, the failure predicate will return True when a thrown
          exception type matches one of the provided types.

          If a predicate function, it will just be returned as is.

         :return: callable (Type[Exception], Exception) -> bool
    z9expected_exception cannot be a string. Did you mean name?z1expected_exception does not look like a predicate)
r
r�	Exceptionr�iter�
isinstance�STRING_TYPES�
ValueError�	TypeError�callable)�expected_exception�failure_predicaterrr�build_failure_predicate&s


r&c@s�eZdZdZdZeZdZd*dd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zedd��Zedd��Zedd��Zedd��Zedd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zd(d)�ZdS)+�CircuitBreaker��NcCs�d|_d|_|p|j|_|p |j|_|sTzt|�jd}WntyRt	j
}Yn0t|�|_|pf|j
|_||_t|_t�|_dS)a�
        Construct a circuit breaker.

        :param failure_threshold: break open after this many failures
        :param recovery_timeout: close after this many seconds
        :param expected_exception: either an type of Exception, iterable of Exception types, or a predicate function.
        :param name: name for this circuitbreaker
        :param fallback_function: called when the circuit is opened

           :return: Circuitbreaker instance
           :rtype: Circuitbreaker
        Nr�EXPECTED_EXCEPTION)�
_last_failure�_failure_count�FAILURE_THRESHOLD�_failure_threshold�RECOVERY_TIMEOUT�_recovery_timeout�type�__dict__�KeyErrorr'r*r&�
is_failure�FALLBACK_FUNCTION�_fallback_function�_name�STATE_CLOSED�_stater�_opened)�self�failure_threshold�recovery_timeoutr$�name�fallback_functionrrr�__init__Ns
zCircuitBreaker.__init__cCs
|�|�Sr)�decorate)r;�wrappedrrr�__call__yszCircuitBreaker.__call__cCsdSrr�r;rrr�	__enter__|szCircuitBreaker.__enter__cCs,|r |�||�r ||_|��n|��dS)NF)r4r+�_CircuitBreaker__call_failed�_CircuitBreaker__call_succeeded)r;�exc_type�	exc_value�
_tracebackrrr�__exit__s

zCircuitBreaker.__exit__csn�jdur2z�j�_Wnty0�j�_Yn0t���t��rL�j�n�j�t	�����fdd��}|S)z;
        Applies the circuit breaker to a function
        Ncs:�jr$�jr�j|i|��St�����g|�Ri|��Sr)�openedr?�CircuitBreakerError)�args�kwargs��call�functionr;rr�wrapper�s
z(CircuitBreaker.decorate.<locals>.wrapper)
r7�__qualname__�AttributeError�__name__�CircuitBreakerMonitor�registerr	�call_generatorrQr)r;rRrSrrPrrA�s

zCircuitBreaker.decoratecOs6|�||i|��Wd�S1s(0YdS)z�
        Calls the decorated function and applies the circuit breaker
        rules on success or failure
        :param func: Decorated function
        Nr)r;�funcrNrOrrrrQ�szCircuitBreaker.callcosB|�*||i|��D]
}|VqWd�n1s40YdS)z�
        Calls the decorated generator function and applies the circuit breaker
        rules on success or failure
        :param func: Decorated generator function
        Nr)r;rZrNrO�elrrrrY�szCircuitBreaker.call_generatorcCst|_d|_d|_dS)zR
        Close circuit after successful execution and reset failure count
        Nr)r8r9r+r,rDrrr�__call_succeeded�szCircuitBreaker.__call_succeededcCs,|jd7_|j|jkr(t|_t�|_dS)zO
        Count failure and open circuit, if threshold has been reached
        �N)r,r.�
STATE_OPENr9rr:rDrrr�
__call_failed�szCircuitBreaker.__call_failedcCs|jtkr|jdkrtS|jS�Nr)r9r^�open_remaining�STATE_HALF_OPENrDrrr�state�szCircuitBreaker.statecCst��t|jd�S)zq
        The approximate datetime when the circuit breaker will try to recover
        :return: datetime
        )�seconds)r�utcnowrrarDrrr�
open_until�szCircuitBreaker.open_untilcCs*|j|jt�}|dkr"t|�St|�S)zk
        Number of seconds remaining, the circuit breaker stays in OPEN state
        :return: int
        r)r:r0rr
r)r;�remainrrrra�szCircuitBreaker.open_remainingcCs|jSr)r,rDrrr�
failure_count�szCircuitBreaker.failure_countcCs
|jtkSr)rcr8rDrrrr�szCircuitBreaker.closedcCs
|jtkSr)rcr^rDrrrrL�szCircuitBreaker.openedcCs|jSr�r7rDrrrr>�szCircuitBreaker.namecCs|jSr)r+rDrrr�last_failure�szCircuitBreaker.last_failurecCs|jSr)r6rDrrrr?�sz CircuitBreaker.fallback_functioncOs|jSrri�r;rNrOrrr�__str__�szCircuitBreaker.__str__)NNNNN)rV�
__module__rTr-r/rr*r5r@rCrErKrArQrYrGrF�propertyrcrfrarhrrLr>rjr?rlrrrrr'HsJ�
+		
	








r'cs$eZdZ�fdd�Zdd�Z�ZS)rMcs tt|�j|i|��||_dS)zf
        :param circuit_breaker:
        :param args:
        :param kwargs:
        :return:
        N)�superrMr@�_circuit_breaker)r;�circuit_breakerrNrO��	__class__rrr@�szCircuitBreakerError.__init__cOs*d|jj|jj|jjt|jj�|jjfS)NzMCircuit "%s" OPEN until %s (%d failures, %d sec remaining) (last_failure: %r))rpr>rfrh�roundrarjrkrrrrls
�zCircuitBreakerError.__str__)rVrmrTr@rl�
__classcell__rrrrrrM�s
rMc@sXeZdZiZedd��Zedd��Zedd��Zedd��Zed	d
��Z	edd��Z
d
S)rWcCs||j|j<dSr)�circuit_breakersr>)�clsrqrrrrXszCircuitBreakerMonitor.registercCstt|����dkSr`)�len�list�get_open�rwrrr�
all_closedsz CircuitBreakerMonitor.all_closedcCs
|j��Sr)rv�valuesr{rrr�get_circuitssz"CircuitBreakerMonitor.get_circuitscCs|j�|�Sr)rv�get)rwr>rrrr szCircuitBreakerMonitor.getccs|��D]}|jr|VqdSr)r~rL�rw�circuitrrrrz%szCircuitBreakerMonitor.get_openccs|��D]}|jr|VqdSr)r~rr�rrr�
get_closed,sz CircuitBreakerMonitor.get_closedN)rVrmrTrv�classmethodrXr|r~rrzr�rrrrrWs




rWNcCs*t|�r|��|�S||||||d�SdS)N)r<r=r$r>r?)r#rA)r<r=r$r>r?rwrrrr�4s�r�)%�
__future__rrrr�	functoolsrrr�inspectr	r
�typingrr�mathr
r�timer�ImportError�
basestringr �	NameError�bytes�strr8r^rbrr&�objectr'rrMrWr�rrrr�<module>s@
	"3%�

Youez - 2016 - github.com/yon3zu
LinuXploit