summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/pool.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/pool.py')
-rw-r--r--lib/sqlalchemy/pool.py96
1 files changed, 48 insertions, 48 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py
index 4f06bd5d9..0b3d7d0eb 100644
--- a/lib/sqlalchemy/pool.py
+++ b/lib/sqlalchemy/pool.py
@@ -25,7 +25,7 @@ from .util import threading, memoized_property, \
proxies = {}
def manage(module, **params):
- """Return a proxy for a DB-API module that automatically
+ """Return a proxy for a DB-API module that automatically
pools connections.
Given a DB-API 2.0 module and pool management parameters, returns
@@ -64,11 +64,11 @@ reset_none = util.symbol('reset_none')
class Pool(log.Identified):
"""Abstract base class for connection pools."""
- def __init__(self,
- creator, recycle=-1, echo=None,
+ def __init__(self,
+ creator, recycle=-1, echo=None,
use_threadlocal=False,
logging_name=None,
- reset_on_return=True,
+ reset_on_return=True,
listeners=None,
events=None,
_dispatch=None):
@@ -85,8 +85,8 @@ class Pool(log.Identified):
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
+ 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, connections being pulled and retrieved
@@ -119,7 +119,7 @@ class Pool(log.Identified):
:class:`~sqlalchemy.interfaces.PoolListener`-like objects or
dictionaries of callables that receive events when DB-API
connections are created, checked out and checked in to the
- pool. This has been superseded by
+ pool. This has been superseded by
:func:`~sqlalchemy.event.listen`.
"""
@@ -141,7 +141,7 @@ class Pool(log.Identified):
self._reset_on_return = reset_commit
else:
raise exc.ArgumentError(
- "Invalid value for 'reset_on_return': %r"
+ "Invalid value for 'reset_on_return': %r"
% reset_on_return)
self.echo = echo
@@ -190,8 +190,8 @@ class Pool(log.Identified):
"""Return a new :class:`.Pool`, of the same class as this one
and configured with identical creation arguments.
- This method is used in conjunection with :meth:`dispose`
- to close out an entire :class:`.Pool` and create a new one in
+ This method is used in conjunection with :meth:`dispose`
+ to close out an entire :class:`.Pool` and create a new one in
its place.
"""
@@ -204,7 +204,7 @@ class Pool(log.Identified):
This method leaves the possibility of checked-out connections
remaining open, as it only affects connections that are
idle in the pool.
-
+
See also the :meth:`Pool.recreate` method.
"""
@@ -213,11 +213,11 @@ class Pool(log.Identified):
def _replace(self):
"""Dispose + recreate this pool.
-
- Subclasses may employ special logic to
+
+ Subclasses may employ special logic to
move threads waiting on this pool to the
new one.
-
+
"""
self.dispose()
return self.recreate()
@@ -225,8 +225,8 @@ class Pool(log.Identified):
def connect(self):
"""Return a DBAPI connection from the pool.
- The connection is instrumented such that when its
- ``close()`` method is called, the connection will be returned to
+ The connection is instrumented such that when its
+ ``close()`` method is called, the connection will be returned to
the pool.
"""
@@ -372,11 +372,11 @@ def _finalize_fairy(connection, connection_record, pool, ref, echo):
if connection_record is not None:
connection_record.fairy = None
if echo:
- pool.logger.debug("Connection %r being returned to pool",
+ pool.logger.debug("Connection %r being returned to pool",
connection)
if connection_record.finalize_callback:
connection_record.finalize_callback(connection)
- del connection_record.finalize_callback
+ del connection_record.finalize_callback
if pool.dispatch.checkin:
pool.dispatch.checkin(connection, connection_record)
pool._return_conn(connection_record)
@@ -399,13 +399,13 @@ class _ConnectionFairy(object):
rec = self._connection_record = pool._do_get()
conn = self.connection = self._connection_record.get_connection()
rec.fairy = weakref.ref(
- self,
+ self,
lambda ref:_finalize_fairy and _finalize_fairy(conn, rec, pool, ref, _echo)
)
_refs.add(rec)
except:
# helps with endless __getattr__ loops later on
- self.connection = None
+ self.connection = None
self._connection_record = None
raise
if self._echo:
@@ -467,7 +467,7 @@ class _ConnectionFairy(object):
attempts = 2
while attempts > 0:
try:
- self._pool.dispatch.checkout(self.connection,
+ self._pool.dispatch.checkout(self.connection,
self._connection_record,
self)
return self
@@ -510,7 +510,7 @@ class _ConnectionFairy(object):
self._close()
def _close(self):
- _finalize_fairy(self.connection, self._connection_record,
+ _finalize_fairy(self.connection, self._connection_record,
self._pool, None, self._echo)
self.connection = None
self._connection_record = None
@@ -523,7 +523,7 @@ class SingletonThreadPool(Pool):
Options are the same as those of :class:`.Pool`, as well as:
- :param pool_size: The number of threads in which to maintain connections
+ :param pool_size: The number of threads in which to maintain connections
at once. Defaults to five.
:class:`.SingletonThreadPool` is used by the SQLite dialect
@@ -541,12 +541,12 @@ class SingletonThreadPool(Pool):
def recreate(self):
self.logger.info("Pool recreating")
- return self.__class__(self._creator,
- pool_size=self.size,
- recycle=self._recycle,
- echo=self.echo,
+ return self.__class__(self._creator,
+ pool_size=self.size,
+ recycle=self._recycle,
+ echo=self.echo,
logging_name=self._orig_logging_name,
- use_threadlocal=self._use_threadlocal,
+ use_threadlocal=self._use_threadlocal,
_dispatch=self.dispatch)
def dispose(self):
@@ -599,7 +599,7 @@ class DummyLock(object):
class QueuePool(Pool):
"""A :class:`.Pool` that imposes a limit on the number of open connections.
- :class:`.QueuePool` is the default pooling implementation used for
+ :class:`.QueuePool` is the default pooling implementation used for
all :class:`.Engine` objects, unless the SQLite dialect is in use.
"""
@@ -658,18 +658,18 @@ class QueuePool(Pool):
:meth:`unique_connection` method is provided to bypass the
threadlocal behavior installed into :meth:`connect`.
- :param reset_on_return: Determine steps to take on
- connections as they are returned to the pool.
+ :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
+ * True - same as 'rollback', this is here for
backwards compatibility.
* 'commit' - call commit() on the connection,
- to release locks and transaction resources.
+ 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
@@ -681,7 +681,7 @@ class QueuePool(Pool):
that has no transaction support at all,
namely MySQL MyISAM. By not doing anything,
performance can be improved. This
- setting should **never be selected** for a
+ setting should **never be selected** for a
database that supports transactions,
as it will lead to deadlocks and stale
state.
@@ -732,7 +732,7 @@ class QueuePool(Pool):
else:
raise exc.TimeoutError(
"QueuePool limit of size %d overflow %d reached, "
- "connection timed out, timeout %d" %
+ "connection timed out, timeout %d" %
(self.size(), self.overflow(), self._timeout))
self._overflow_lock.acquire()
@@ -749,10 +749,10 @@ class QueuePool(Pool):
def recreate(self):
self.logger.info("Pool recreating")
- return self.__class__(self._creator, pool_size=self._pool.maxsize,
+ return self.__class__(self._creator, pool_size=self._pool.maxsize,
max_overflow=self._max_overflow,
- timeout=self._timeout,
- recycle=self._recycle, echo=self.echo,
+ timeout=self._timeout,
+ recycle=self._recycle, echo=self.echo,
logging_name=self._orig_logging_name,
use_threadlocal=self._use_threadlocal,
_dispatch=self.dispatch)
@@ -777,9 +777,9 @@ class QueuePool(Pool):
def status(self):
return "Pool size: %d Connections in pool: %d "\
"Current Overflow: %d Current Checked out "\
- "connections: %d" % (self.size(),
- self.checkedin(),
- self.overflow(),
+ "connections: %d" % (self.size(),
+ self.checkedin(),
+ self.overflow(),
self.checkedout())
def size(self):
@@ -822,11 +822,11 @@ class NullPool(Pool):
def recreate(self):
self.logger.info("Pool recreating")
- return self.__class__(self._creator,
- recycle=self._recycle,
- echo=self.echo,
+ return self.__class__(self._creator,
+ recycle=self._recycle,
+ echo=self.echo,
logging_name=self._orig_logging_name,
- use_threadlocal=self._use_threadlocal,
+ use_threadlocal=self._use_threadlocal,
_dispatch=self.dispatch)
def dispose(self):
@@ -915,7 +915,7 @@ class AssertionPool(Pool):
def recreate(self):
self.logger.info("Pool recreating")
- return self.__class__(self._creator, echo=self.echo,
+ return self.__class__(self._creator, echo=self.echo,
logging_name=self._orig_logging_name,
_dispatch=self.dispatch)
@@ -982,7 +982,7 @@ class _DBProxy(object):
try:
if key not in self.pools:
kw.pop('sa_pool_key', None)
- pool = self.poolclass(lambda:
+ pool = self.poolclass(lambda:
self.module.connect(*args, **kw), **self.kw)
self.pools[key] = pool
return pool
@@ -1021,6 +1021,6 @@ class _DBProxy(object):
return kw['sa_pool_key']
return tuple(
- list(args) +
+ list(args) +
[(k, kw[k]) for k in sorted(kw)]
)