U kf2@sddlmZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd l m Z dd l mZejse sd dlmZd dlmZnddlmZddlmZedegefdZdddddZGddde ZGdddZdS)) annotationsN)Any)Callable)Optional)TypeVar)exc)util)HAS_CYEXTENSION)Protocol)Self)_distill_params_20)_distill_raw_params_C)boundstrzCallable[[_C], _C])keyreturncstjfdd}|S)zDecorator, memoize a function in a connection.info stash. Only applicable to functions which take no arguments other than a connection. The memo will be stored in ``connection.info[key]``. csF|}z |jWStk r@||||j<}|YSXdSN)connectinfoKeyError)fnself connectionvalrF/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/engine/util.py decorated+s  z%connection_memoize..decorated)r decorator)rr rrrconnection_memoize$sr"c@seZdZUded<dS) _TConsSubjectzOptional[TransactionalContext]_trans_context_managerN)__name__ __module__ __qualname____annotations__rrrrr#7s r#c@seZdZUdZdZded<ddddZddd d Zddd d Zd dddZ ddddZ ddddZ ddddZ e d ddddZddddZddddddd Zd!S)"TransactionalContextzApply Python context manager behavior to transaction objects. Performs validation to ensure the subject of the transaction is not used if the transaction were ended prematurely. )_outer_trans_ctx_trans_subject __weakref__zOptional[_TConsSubject]r+bool)rcCs tdSrNotImplementedErrorrrrr_transaction_is_activeGsz+TransactionalContext._transaction_is_activecCs tdSrr.r0rrr_transaction_is_closedJsz+TransactionalContext._transaction_is_closedcCs tdS)aindicates the object is in a state that is known to be acceptable for rollback() to be called. This does not necessarily mean rollback() will succeed or not raise an error, just that there is currently no state detected that indicates rollback() would fail or emit warnings. It also does not mean that there's a transaction in progress, as it is usually safe to call rollback() even if no transaction is present. .. versionadded:: 1.4.28 Nr.r0rrr_rollback_can_be_calledMsz,TransactionalContext._rollback_can_be_calledr#cCs tdSrr.r0rrr _get_subject^sz!TransactionalContext._get_subjectNonecCs tdSrr.r0rrrcommitaszTransactionalContext.commitcCs tdSrr.r0rrrrollbackdszTransactionalContext.rollbackcCs tdSrr.r0rrrclosegszTransactionalContext.close)subjectrcCs |j}|r|stddS)NzCan't operate on closed transaction inside context manager. Please complete the context manager before emitting further commands.)r$r1rZInvalidRequestError)clsr9 trans_contextrrr_trans_ctx_checkjs z%TransactionalContext._trans_ctx_checkr cCs$|}|j}||_||_||_|Sr)r4r$r*r+)rr9r;rrr __enter__us zTransactionalContext.__enter__r)type_value tracebackrc Cst|dd}|dkp|j|k }|dkr|rzBz |Wn0t| r^| W5QRXYnXW5|s|dk st|j|_d|_|_XnVz.|s| s| n| r| W5|s|dk st|j|_d|_|_XdS)Nr+) getattrr$r1AssertionErrorr*r+r6r Z safe_reraiser3r7r2r8)rr>r?r@r9Zout_of_band_exitrrr__exit__s0       zTransactionalContext.__exit__N)r%r&r'__doc__ __slots__r(r1r2r3r4r6r7r8 classmethodr<r=rCrrrrr);s   r)) __future__rtypingrrrrrr Z util._has_cyr Z util.typingr r TYPE_CHECKINGZ_py_utilrrZsqlalchemy.cyextension.utilrr"r#r)rrrrs&