diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-26 16:31:52 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-26 16:31:52 -0400 |
| commit | 761c8ff15de16e572a6e1382cae76d734bd411e7 (patch) | |
| tree | 206e5f7666adf2754bf77c5719206282441bf1a3 /lib/sqlalchemy/pool.py | |
| parent | dc0d581d5d10589e02d8d38698afb470559d22f2 (diff) | |
| download | sqlalchemy-761c8ff15de16e572a6e1382cae76d734bd411e7.tar.gz | |
- work on fixing some race-condition failures:
1. make sure pool._invalidate() sets the timestamp up before
invalidating the target connection. we can otherwise show how the
conn.invalidate() + pool._invalidate() can lead to an extra connection
being made.
2. to help with that, soften up the check on connection.invalidate()
when connection is already closed. a warning is fine here
3. add a mutex to test_max_overflow() when we connect, because the way
we're using mock depends on an iterator, that needs to be synchronized
Diffstat (limited to 'lib/sqlalchemy/pool.py')
| -rw-r--r-- | lib/sqlalchemy/pool.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 7fc4fc659..799443546 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -277,7 +277,7 @@ class Pool(log.Identified): return _ConnectionRecord(self) - def _invalidate(self, connection): + def _invalidate(self, connection, exception=None): """Mark all connections established within the generation of the given connection as invalidated. @@ -291,6 +291,8 @@ class Pool(log.Identified): rec = getattr(connection, "_connection_record", None) if not rec or self._invalidate_time < rec.starttime: self._invalidate_time = time.time() + if getattr(connection, 'is_valid', False): + connection.invalidate(exception) def recreate(self): @@ -733,7 +735,8 @@ class _ConnectionFairy(object): """ if self.connection is None: - raise exc.InvalidRequestError("This connection is closed") + util.warn("Can't invalidate an already-closed connection.") + return if self._connection_record: self._connection_record.invalidate(e=e) self.connection = None |
