ok
Direktori : /opt/imunify360/venv/lib64/python3.11/site-packages/playhouse/__pycache__/ |
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/playhouse/__pycache__/pool.cpython-311.pyc |
� >�Dg�, � � � d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddl mZ ddl mZ n# e $ r dxZ xZZY nw xY wddlmZ dd lmZ dd lmZ ej d� � Zd� Z G d � de� � Z edd� � Z G d� de� � Z G d� dee� � Z G d� de� � Z G d� dee� � Z ddlmZ G d� dee� � Zn # e $ r dZY nw xY w G d� de� � Z G d� de e� � Z! dd l"m#Z# G d!� d"e e#� � Z$n # e $ r dZ$Y nw xY w dd#l"m%Z% G d$� d%e e%� � Z&dS # e $ r dZ&Y dS w xY w)&aG Lightweight connection pooling for peewee. In a multi-threaded application, up to `max_connections` will be opened. Each thread (or, if using gevent, greenlet) will have it's own connection. In a single-threaded application, only one connection will be created. It will be continually recycled until either it exceeds the stale timeout or is closed explicitly (using `.manual_close()`). By default, all your application needs to do is ensure that connections are closed when you are finished with them, and they will be returned to the pool. For web applications, this typically means that at the beginning of a request, you will open a connection, and when you return a response, you will close the connection. Simple Postgres pool example code: # Use the special postgresql extensions. from playhouse.pool import PooledPostgresqlExtDatabase db = PooledPostgresqlExtDatabase( 'my_app', max_connections=32, stale_timeout=300, # 5 minutes. user='postgres') class BaseModel(Model): class Meta: database = db That's it! � N)� namedtuple)�chain)�TRANSACTION_STATUS_IDLE)�TRANSACTION_STATUS_INERROR)�TRANSACTION_STATUS_UNKNOWN)� MySQLDatabase)�PostgresqlDatabase)�SqliteDatabasezpeewee.poolc �` � | �+t | t t f� � st | � � S | S �N)� isinstance�int�float)�vals �E/opt/imunify360/venv/lib64/python3.11/site-packages/playhouse/pool.py�make_intr 9 s) � � ��z�#��U�|�<�<���3�x�x���J� c � � e Zd ZdS )�MaxConnectionsExceededN��__name__� __module__�__qualname__� r r r r ? s � � � � � � � r r �PoolConnection)� timestamp� connection�checked_outc � � � e Zd Z d� fd� Z d� fd� Zd� fd� Z� fd�Zd� Zd � Zd � Z d� fd� Z d� Zd � Zdd�Z d� Z� xZS )�PooledDatabase� Nc �4 �� t |� � | _ t |� � | _ t |� � | _ | j dk rt d� � | _ g | _ i | _ t | _ t t | � � j |fi |�� d S �Nr �inf)r �_max_connections�_stale_timeout� _wait_timeoutr �_connections�_in_use�id�conn_key�superr �__init__)�self�database�max_connections� stale_timeout�timeout�kwargs� __class__s �r r- zPooledDatabase.__init__G s� �� � (�� 9� 9���&�}�5�5���%�g�.�.������"�"�!&�u���D�� ��� ��� �� �,��n�d�#�#�,�X�@�@��@�@�@�@�@r c � �� t t | � � j |fi |�� |�t |� � | _ |�t |� � | _ |�5t |� � | _ | j dk rt d� � | _ d S d S d S r# )r, r �initr r% r&