/opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__
NameSizeModeActions
apsw_ext.cpython-38.opt-1.pyc73210644editdlrm
apsw_ext.cpython-38.pyc73210644editdlrm
berkeleydb.cpython-38.opt-1.pyc31220644editdlrm
berkeleydb.cpython-38.pyc31220644editdlrm
csv_loader.cpython-38.opt-1.pyc1980644editdlrm
csv_loader.cpython-38.pyc1980644editdlrm
csv_utils.cpython-38.opt-1.pyc109790644editdlrm
csv_utils.cpython-38.pyc109790644editdlrm
dataset.cpython-38.opt-1.pyc128740644editdlrm
dataset.cpython-38.pyc128740644editdlrm
db_url.cpython-38.opt-1.pyc30350644editdlrm
db_url.cpython-38.pyc30350644editdlrm
djpeewee.cpython-38.opt-1.pyc55580644editdlrm
djpeewee.cpython-38.pyc55580644editdlrm
fields.cpython-38.opt-1.pyc121430644editdlrm
fields.cpython-38.pyc121430644editdlrm
flask_utils.cpython-38.opt-1.pyc57910644editdlrm
flask_utils.cpython-38.pyc57910644editdlrm
gfk.cpython-38.opt-1.pyc58710644editdlrm
gfk.cpython-38.pyc58710644editdlrm
hybrid.cpython-38.opt-1.pyc21650644editdlrm
hybrid.cpython-38.pyc21650644editdlrm
kv.cpython-38.opt-1.pyc66240644editdlrm
kv.cpython-38.pyc66240644editdlrm
migrate.cpython-38.opt-1.pyc216770644editdlrm
migrate.cpython-38.pyc216770644editdlrm
pool.cpython-38.opt-1.pyc77530644editdlrm
pool.cpython-38.pyc77530644editdlrm
postgres_ext.cpython-38.opt-1.pyc162510644editdlrm
postgres_ext.cpython-38.pyc162510644editdlrm
read_slave.cpython-38.opt-1.pyc17760644editdlrm
read_slave.cpython-38.pyc17760644editdlrm
reflection.cpython-38.opt-1.pyc175770644editdlrm
reflection.cpython-38.pyc175770644editdlrm
shortcuts.cpython-38.opt-1.pyc54440644editdlrm
shortcuts.cpython-38.pyc54440644editdlrm
signals.cpython-38.opt-1.pyc29840644editdlrm
signals.cpython-38.pyc29840644editdlrm
sqlcipher_ext.cpython-38.opt-1.pyc45390644editdlrm
sqlcipher_ext.cpython-38.pyc45390644editdlrm
sqliteq.cpython-38.opt-1.pyc93060644editdlrm
sqliteq.cpython-38.pyc93060644editdlrm
sqlite_ext.cpython-38.opt-1.pyc349610644editdlrm
sqlite_ext.cpython-38.pyc349610644editdlrm
sqlite_udf.cpython-38.opt-1.pyc157870644editdlrm
sqlite_udf.cpython-38.pyc157870644editdlrm
test_utils.cpython-38.opt-1.pyc41130644editdlrm
test_utils.cpython-38.pyc41130644editdlrm
__init__.cpython-38.opt-1.pyc1600644editdlrm
__init__.cpython-38.pyc1600644editdlrm
Edit: /opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/pool.cpython-38.pyc (7753B)
U SW @s.dZddlZddlZddlZddlmZddlmZddlmZedZ ddZ Gd d d e Z Gd d d e eZ Gd dde ZGdddeeZz"ddlmZGdddeeZWnek rYnXGddde ZGdddeeZz"ddlmZGdddeeZWnek r(YnXdS)ap 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! In some situations you may want to manage your connections more explicitly. Since peewee stores the active connection in a threadlocal, this typically would mean that there could only ever be one connection open per thread. For most applications this is desirable, but if you would like to manually manage multiple connections you can create an *ExecutionContext*. Execution contexts allow finer-grained control over managing multiple connections to the database. When an execution context is initialized (either as a context manager or as a decorated function), a separate connection will be used for the duration of the wrapped block. You can also choose whether to wrap the block in a transaction. Execution context examples (using above `db` instance): with db.execution_context() as ctx: # A new connection will be opened or pulled from the pool of available # connections. Additionally, a transaction will be started. user = User.create(username='charlie') # When the block ends, the transaction will be committed and the connection # will be returned to the pool. @db.execution_context(with_transaction=False) def do_something(foo, bar): # When this function is called, a separate connection is made and will # be closed when the function returns. N) MySQLDatabase)PostgresqlDatabase)SqliteDatabasez peewee.poolcCs"|dk rt|ttfst|S|SN) isinstanceintfloat)valr A/opt/alt/python38/lib64/python3.8/site-packages/playhouse/pool.pymake_intHsr csfeZdZdfdd Zdfdd ZfddZd d Zd d Zdfdd ZddZ ddZ Z S)PooledDatabaseNc sFt||_t||_g|_i|_t|_t|_t t |j |f|dSr) r max_connections stale_timeout _connections_in_useset_closedidconn_keysuperr __init__)selfdatabaserrkwargs __class__r r rOs  zPooledDatabase.__init__c s<tt|j|f||dk r&t||_|dk r8t||_dSr)rr initr rr)rrrrconnect_kwargsrr r rZs  zPooledDatabase.initcs zt|j\}}||}Wn*tk rHd}}tdYqYqX|||rxtd|d}}|j |q|j r| |rtd|| |d|j |d}}qqq|dkr|j rt|j|j krtdtt|j||}t}||}td|||j|<|S)Nz No connection available in pool.zConnection %s was closed.z!Connection %s was stale, closing.TzExceeded maximum connections.zCreated new connection %s.)heapqheappoprr IndexErrorloggerdebug _is_closedrdiscardr _is_stale_closerlenr ValueErrorrr _connecttime)rargsrtsconnkeyrr r r+bs8            zPooledDatabase._connectcCst||jkSr)r,r)r timestampr r r r'szPooledDatabase._is_stalecCs ||jkSr)r)rr0r/r r r r%szPooledDatabase._is_closedFcs||}|r,|j|tt||nh||jkr|j|}|j|=|jrv||rvt d|tt||nt d|t |j ||fdS)NzClosing stale connection %s.zReturning %s to pool.)rraddrr r(rrr'r#r$r heappushr)rr/ close_connr0r.rr r r(s      zPooledDatabase._closecCs4|}|||||s0|j|dddS)zS Close the underlying connection without returning it to the pool. Tr4N)get_conncloser%rr()rr/r r r manual_closeszPooledDatabase.manual_closecCs"|jD]\}}|j|ddqdS)z< Close all connections managed by the pool. Tr5N)rr()r_r/r r r close_allszPooledDatabase.close_all)rN)NN)F) __name__ __module__ __qualname__rrr+r'r%r(r8r: __classcell__r r rr r Ns  , r cseZdZfddZZS)PooledMySQLDatabasecs:tt|||}|s6z|dWnd}YnX|S)NFT)rr?r%Zping)rr0r/ is_closedrr r r%s zPooledMySQLDatabase._is_closedr;r<r=r%r>r r rr r?sr?cseZdZfddZZS)_PooledPostgresqlDatabasecs$tt|||}|s t|j}|Sr)rrBr%boolclosedrr0r/rDrr r r%s z$_PooledPostgresqlDatabase._is_closedrAr r rr rBsrBc@s eZdZdS)PooledPostgresqlDatabaseNr;r<r=r r r r rFsrF)PostgresqlExtDatabasec@s eZdZdS)PooledPostgresqlExtDatabaseNrGr r r r rIsrIcseZdZfddZZS)_PooledSqliteDatabasecs4tt|||}|s0z |jWnYdSX|S)NT)rrJr% total_changesrErr r r%s z _PooledSqliteDatabase._is_closedrAr r rr rJsrJc@s eZdZdS)PooledSqliteDatabaseNrGr r r r rLsrL)SqliteExtDatabasec@s eZdZdS)PooledSqliteExtDatabaseNrGr r r r rNsrN)__doc__r loggingr,peeweerrr getLoggerr#r objectr r?rBrFZplayhouse.postgres_extrHrI ImportErrorrJrLZplayhouse.sqlite_extrMrNr r r r s0<    f