HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/__pycache__/util.cpython-310.pyc
o

���g2�@s�ddlmZddlZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
l
mZddlm
Z
ddlmZejsEesRd
dlmZd
dlmZnddlmZddlmZedegefd�Zddd�ZGdd�de
�ZGdd�d�ZdS)�)�annotationsN)�Any)�Callable)�Optional)�TypeVar�)�exc)�util)�HAS_CYEXTENSION)�Protocol)�Self�)�_distill_params_20)�_distill_raw_params�_C)�bound�key�str�return�Callable[[_C], _C]cstj�fdd��}|S)z�Decorator, 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]``.
    cs@|��}z|j�WSty|||�|j�<}|YSw�N)�connect�info�KeyError)�fn�self�
connection�val�r��A/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/util.py�	decorated+s�z%connection_memoize.<locals>.decorated)r	�	decorator)rr!rrr �connection_memoize$sr#c@seZdZUded<dS)�
_TConsSubjectzOptional[TransactionalContext]�_trans_context_managerN)�__name__�
__module__�__qualname__�__annotations__rrrr r$7s
r$c@s�eZdZUdZdZded<d$dd�Zd$d	d
�Zd$dd�Zd%dd�Z	d&dd�Z
d&dd�Zd&dd�Ze
d'dd��Zd(dd�Zd)d!d"�Zd#S)*�TransactionalContextz�Apply 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,r�boolcC�t��r��NotImplementedError�rrrr �_transaction_is_activeG�z+TransactionalContext._transaction_is_activecCr/rr0r2rrr �_transaction_is_closedJr4z+TransactionalContext._transaction_is_closedcCr/)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

        r0r2rrr �_rollback_can_be_calledMsz,TransactionalContext._rollback_can_be_calledr$cCr/rr0r2rrr �_get_subject^r4z!TransactionalContext._get_subject�NonecCr/rr0r2rrr �commitar4zTransactionalContext.commitcCr/rr0r2rrr �rollbackdr4zTransactionalContext.rollbackcCr/rr0r2rrr �closegr4zTransactionalContext.close�subjectcCs$|j}|r|��st�d��dSdS)Nz�Can't operate on closed transaction inside context manager.  Please complete the context manager before emitting further commands.)r%r3r�InvalidRequestError)�clsr<�
trans_contextrrr �_trans_ctx_checkjs��z%TransactionalContext._trans_ctx_checkrcCs$|��}|j}||_||_||_|Sr)r7r%r+r,)rr<r?rrr �	__enter__uszTransactionalContext.__enter__�type_r�value�	tracebackcCsJt|dd�}|dup|j|u}|durg|��rgz<z|��Wn t���|��r/|��Wd�n1s9wYYW|sL|dusHJ�|j|_d|_	|_dS|s`|dus\J�|j|_d|_	|_wz*|��su|�
�st|��n|��r}|��W|s�|dus�J�|j|_d|_	|_dS|s�|dus�J�|j|_d|_	|_w)Nr,)�getattrr%r3r9r	�safe_reraiser6r:r+r,r5r;)rrBrCrDr<�out_of_band_exitrrr �__exit__�sJ
�
�������zTransactionalContext.__exit__N)rr.)rr$)rr8)r<r$rr8)rr)rBrrCrrDrrr8)r&r'r(�__doc__�	__slots__r)r3r5r6r7r9r:r;�classmethodr@rArHrrrr r*;s









r*)rrrr)�
__future__r�typingrrrr�rr	�util._has_cyr
�util.typingrr�
TYPE_CHECKING�_py_utilrr�sqlalchemy.cyextension.utilrr#r$r*rrrr �<module>s(