/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool
Edit: /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyo (34626B)
ó
ÃÌ4]c @ s/ d Z d d l m Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m
Z
d d
l
m Z e
j d ƒ Z
e
j d ƒ Z e
j d
ƒ Z d e f d „ ƒ YZ d e j f d „ ƒ YZ d e f d „ ƒ YZ e d „ Z e ƒ Z d e f d „ ƒ YZ d S( s' Base constructs for connection pools.
iÿÿÿÿ( t dequeNi ( t event( t exc( t
interfaces( t log( t util( t threadingt reset_rollbackt reset_committ
reset_nonet _ConnDialectc B s2 e Z d Z d „ Z d „ Z d „ Z d „ Z RS( sê partial implementation of :class:`.Dialect`
which provides DBAPI connection methods.
When a :class:`.Pool` is combined with an :class:`.Engine`,
the :class:`.Engine` replaces this with its own
:class:`.Dialect`.
c C s | j ƒ d S( N( t rollback( t selft dbapi_connection( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt do_rollback) s c C s | j ƒ d S( N( t commit( R R
( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt do_commit, s c C s | j ƒ d S( N( t close( R R
( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt do_close/ s c C s t d ƒ ‚ d S( NsJ The ping feature requires that a dialect is passed to the connection pool.( t NotImplementedError( R R
( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt do_ping2 s ( t __name__t
__module__t __doc__R R R R ( ( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyR
s
t Poolc B s e Z d Z e ƒ Z e j d d d d ƒ d d e d e d d d e d d „
ƒ Z
e d „ ƒ Z e j
d
„ ƒ Z d „ Z d „ Z e j d d
ƒ d „ ƒ Z d „ Z d „ Z d e d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( s) Abstract base class for connection pools.t use_threadlocals 1.3sf The :paramref:`.Pool.use_threadlocal` parameter is deprecated and will be removed in a future release.t listenerss 0.7s :class:`.PoolListener` is deprecated in favor of the :class:`.PoolEvents` listener interface. The :paramref:`.Pool.listeners` parameter will be removed in a future release.iÿÿÿÿc C s | r | | _ | _ n d | _ t j | d | ƒt j ƒ | _ | | _ | | _ d | _
| | _ |
| _ | d t
t f k r’ t | _ nU | d d t t f k r¶ t | _ n1 | d t f k rÔ t | _ n t j d | ƒ ‚ | | _ | r| j j | d t ƒn | r!| | _ n | rTx* | D] \ } }
t j | |
| ƒ q.Wn | r{x | D] } | j | ƒ qaWn d S( s
Construct a Pool.
:param creator: a callable function that returns a DB-API
connection object. The function will be called with
parameters.
:param recycle: If set to a value other than -1, number of
seconds between connection recycling, which means upon
checkout, if this timeout is surpassed the connection will be
closed and replaced with a newly opened connection. Defaults to -1.
:param logging_name: String identifier which will be used within
the "name" field of logging records generated within the
"sqlalchemy.pool" logger. Defaults to a hexstring of the object's
id.
:param echo: if True, the connection pool will log
informational output such as when connections are invalidated
as well as when connections are recycled to the default log handler,
which defaults to ``sys.stdout`` for output.. If set to the string
``"debug"``, the logging will include pool checkouts and checkins.
The :paramref:`.Pool.echo` parameter can also be set from the
:func:`.create_engine` call by using the
:paramref:`.create_engine.echo_pool` parameter.
.. seealso::
:ref:`dbengine_logging` - further detail on how to configure
logging.
:param use_threadlocal: If set to True, repeated calls to
:meth:`connect` within the same application thread will be
guaranteed to return the same connection object that is already
checked out. This is a legacy use case and the flag has no
effect when using the pool with a :class:`.Engine` object.
:param reset_on_return: Determine steps to take on
connections as they are returned to the pool.
reset_on_return can have any of these values:
* ``"rollback"`` - call rollback() on the connection,
to release locks and transaction resources.
This is the default value. The vast majority
of use cases should leave this value set.
* ``True`` - same as 'rollback', this is here for
backwards compatibility.
* ``"commit"`` - call commit() on the connection,
to release locks and transaction resources.
A commit here may be desirable for databases that
cache query plans if a commit is emitted,
such as Microsoft SQL Server. However, this
value is more dangerous than 'rollback' because
any data changes present on the transaction
are committed unconditionally.
* ``None`` - don't do anything on the connection.
This setting should generally only be made on a database
that has no transaction support at all,
namely MySQL MyISAM; when used on this backend, performance
can be improved as the "rollback" call is still expensive on
MySQL. It is **strongly recommended** that this setting not be
used for transaction-supporting databases in conjunction with
a persistent pool such as :class:`.QueuePool`, as it opens
the possibility for connections still in a transaction to be
idle in the pool. The setting may be appropriate in the
case of :class:`.NullPool` or special circumstances where
the connection pool in use is not being used to maintain connection
lifecycle.
* ``False`` - same as None, this is here for
backwards compatibility.
:param events: a list of 2-tuples, each of the form
``(callable, target)`` which will be passed to :func:`.event.listen`
upon construction. Provided here so that event listeners
can be assigned via :func:`.create_engine` before dialect-level
listeners are applied.
:param listeners: A list of :class:`.PoolListener`-like objects or
dictionaries of callables that receive events when DB-API
connections are created, checked out and checked in to the
pool.
:param dialect: a :class:`.Dialect` that will handle the job
of calling rollback(), close(), or commit() on DBAPI connections.
If omitted, a built-in "stub" dialect is used. Applications that
make use of :func:`~.create_engine` should not use this parameter
as it is handled by the engine creation strategy.
.. versionadded:: 1.1 - ``dialect`` is now a public parameter
to the :class:`.Pool`.
:param pre_ping: if True, the pool will emit a "ping" (typically
"SELECT 1", but is dialect-specific) on the connection
upon checkout, to test if the connection is alive or not. If not,
the connection is transparently re-connected and upon success, all
other pooled connections established prior to that timestamp are
invalidated. Requires that a dialect is passed as well to
interpret the disconnection error.
.. versionadded:: 1.2
t echoflagi R t noneR s' Invalid value for 'reset_on_return': %rt only_propagateN( t logging_namet _orig_logging_namet NoneR t instance_loggerR t localt _threadconnst _creatort _recyclet _invalidate_timet _use_threadlocalt _pre_pingt TrueR t _reset_on_returnt FalseR R R t
ArgumentErrort echot dispatcht _updatet _dialectR t listent add_listener( R t creatort recycleR- R R t reset_on_returnR t eventst dialectt pre_pingt _dispatcht fnt targett l( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt __init__? s: „
c C s | j d S( NR$ ( t __dict__( R ( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyR$ ç s c C s# | | j d <| j | ƒ | _ d S( NR$ ( R> t _should_wrap_creatort _invoke_creator( R R3 ( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyR$ ë s
c s¼ y t j | j d t ƒ} Wn t k
r9 ‡ f d † SX| d d k rZ t | d ƒ p] d } t | d ƒ | } | d | d f d g d f k r› ˆ S| d k r« ˆ S‡ f d † Sd S(
sl Detect if creator accepts a single argument, or is sent
as a legacy style no-arg function.
t no_selfc s ˆ ƒ S( N( ( t crec( R3 ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt
ù t i i t connection_recordi c s ˆ ƒ S( N( ( RB ( R3 ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyRC RD N( N( R t get_callable_argspecR$ R) t TypeErrorR t len( R R3 t argspect defaultedt positionals( ( R3 sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyR? ð s
&#c C sX | j j d | ƒ y | j j | ƒ Wn* t k
rS | j j d | d t ƒn Xd S( Ns Closing connection %rs Exception closing connection %rt exc_info( t loggert debugR0 R t Exceptiont errorR) ( R t
connection( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt _close_connection
s
s• The :meth:`.Pool.add_listener` method is deprecated and will be removed in a future release. Please use the :class:`.PoolEvents` listener interface.c C s t j j | | ƒ d S( s Add a :class:`.PoolListener`-like object to this pool.
``listener`` may be an object that implements some or all of
PoolListener, or a dictionary of callables containing implementations
of some or all of the named methods in PoolListener.
N( R t PoolListenert _adapt_listener( R t listener( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyR2 s c C s
t j | ƒ S( s’ Produce a DBAPI connection that is not referenced by any
thread-local context.
This method is equivalent to :meth:`.Pool.connect` when the
:paramref:`.Pool.use_threadlocal` flag is not set to True.
When :paramref:`.Pool.use_threadlocal` is True, the
:meth:`.Pool.unique_connection` method provides a means of bypassing
the threadlocal context.
( t _ConnectionFairyt _checkout( R ( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt unique_connection$ s c C s
t | ƒ S( s6 Called by subclasses to create a new ConnectionRecord.( t _ConnectionRecord( R ( ( sG /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/pool/base.pyt _create_connection1 s c C si t | d d ƒ } | s+ | j | j k r= t j ƒ | _ n | re t | d t ƒ re | j | ƒ n d S( sš Mark all connections established within the generation
of the given connection as invalidated.
If this pool's last invalidate time is before when the given
connection was created, update the timestamp til now. Otherwise,
no action is performed.
Connections with a start time prior to this pool's invalidation
time will be recycled upon next checkout.
t _connection_recordt is_validN( t getattrR R&