File: //opt/imunify360/venv/lib64/python3.11/site-packages/playhouse/__pycache__/pool.cpython-311.pyc
�
����;� �( � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
mZ ddl
mZ ddl
m
Z
n# e$ r dxZxZZ
Y nw xY w ddlmZ n# e$ r Y nw xY wdd lmZ dd
lmZ ddlmZ ej d� � Zd
� Z G d� de� � Z edd� � Z G d� de� � Zd� Z G d� de� � Z G d� dee� � Z G d� de� � Z G d� de e� � Z! ddl"m#Z# G d� de e#� � Z$n
# e$ r dZ$Y nw xY w dd l%m&Z& G d!� d"ee&� � Z'n
# e$ r dZ'Y nw xY w G d#� d$e� � Z( G d%� d&e(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)�TransactionStatus)�
MySQLDatabase)�PostgresqlDatabase)�SqliteDatabasezpeewee.poolc �` � | �+t | t t f� � st | � � S | S �N)�
isinstance�int�float)�vals ��/srv/buildsys-work-dir/castor/build_node/builder-0/TMJYY/unpkd_srcs/imunify360-venv-2.6.0/opt/imunify360/venv/lib/python3.11/site-packages/playhouse/pool.py�make_intr >