o
    PDi~                     @   sD   d dl Z ddlmZ G dd dZe ZdddZdefd	d
ZdS )    N   )errorsc                   @   s4   e Zd ZdZdd Zdd Zdd Zedd	 Zd
S )DriverModeManagera  
    Manages the mode the driver is using. The "thin_mode" flag contains the
    current state:
        None: neither thick nor thin implementation has been used yet
        False: thick implementation is being used
        True: thin implementation is being used
    The "requested_thin_mode" is set to the mode that is being requested, but
    only while initialization is taking place (otherwise, it contains the value
    None):
        False: thick implementation is being initialized
        True: thin implementation is being initialized
    The condition is used to ensure that only one thread is performing
    initialization.
    c                 C   s   d | _ d | _t | _d S N)	thin_moderequested_thin_mode	threading	Condition	conditionself r   M/var/www/Datamplify/venv/lib/python3.10/site-packages/oracledb/driver_mode.py__init__A   s   zDriverModeManager.__init__c                 C   s   | S r   r   r   r   r   r   	__enter__F   s   zDriverModeManager.__enter__c                 C   sf   | j & |d u r|d u r|d u r| jd ur| j| _d | _| j   W d    d S 1 s,w   Y  d S r   )r
   r   r   notify)r   exc_type	exc_valueexc_tbr   r   r   __exit__I   s   
"zDriverModeManager.__exit__c                 C   s   | j d ur| j S | jS r   )r   r   r   r   r   r   thinU   s   
zDriverModeManager.thinN)	__name__
__module____qualname____doc__r   r   r   propertyr   r   r   r   r   r   1   s    r   c                 C   s   t ji t jdu r$t jdurt j  t jdu r#| du r dt _n4| t _n(| durD| t jkr\| r6ttj n.ttj W d   t S W d   t S W d   t S W d   t S W d   t S W d   t S 1 sow   Y  t S )zw
    Returns the manager, but only after ensuring that no other threads are
    attempting to initialize the mode.
    NT)	managerr
   r   r   waitr   
_raise_errERR_THICK_MODE_ENABLED#ERR_THIN_CONNECTION_ALREADY_CREATED)r   r   r   r   get_manager_   sB   










r!   returnc                   C   s   t jdurt jS dS )u  
    Returns a boolean indicating if python-oracledb is in Thin mode.

    Immediately after python-oracledb is imported, this function will return
    *True* indicating that python-oracledb defaults to Thin mode. If a call to
    :func:`oracledb.init_oracle_client()` returns successfully, then a
    subsequent call to ``is_thin_mode()`` will return False indicating that
    Thick mode is enabled. Once the first standalone connection or connection
    pool is created, or a successful call to ``oracledb.init_oracle_client()``
    is made, or :meth:`oracledb.enable_thin_mode()` is called, then
    python-oracledb’s mode is fixed and the value returned by
    ``is_thin_mode()`` will never change for the lifetime of the process.

    The attribute :attr:`Connection.thin` can be used to check a connection's
    mode. The attribute :attr:`ConnectionPool.thin` can be used to check a
    pool's mode.
    NT)r   r   r   r   r   r   is_thin_modex   s   
r#   r   )r    r   r   r   r!   boolr#   r   r   r   r   <module>   s   !+
