diff options
| author | rdw <rdw@eniac20.lindenlab.com> | 2008-09-06 19:42:53 -0700 |
|---|---|---|
| committer | rdw <rdw@eniac20.lindenlab.com> | 2008-09-06 19:42:53 -0700 |
| commit | 5c664ecdd910a877dca87874d70dc24ff440351f (patch) | |
| tree | 166a0e3e111f019a2ad549afe03a4b98ec2f4845 /eventlet/db_pool.py | |
| parent | 1e43578d5fa91c6c9d7ab5efb913e64d0dc7206b (diff) | |
| download | eventlet-5c664ecdd910a877dca87874d70dc24ff440351f.tar.gz | |
Changed ConnectionTimeout to ConnectTimeout, added unit test for connection timeout, and a benchmark unit test so we can see how much overhead the various pools add. Added testing of raw connections to the mix.
Diffstat (limited to 'eventlet/db_pool.py')
| -rw-r--r-- | eventlet/db_pool.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/eventlet/db_pool.py b/eventlet/db_pool.py index d0803eb..c08674a 100644 --- a/eventlet/db_pool.py +++ b/eventlet/db_pool.py @@ -32,7 +32,7 @@ from eventlet.pools import Pool from eventlet.processes import DeadProcess from eventlet import api -class ConnectionTimeout(Exception): +class ConnectTimeout(Exception): pass class DatabaseConnector(object): @@ -96,7 +96,7 @@ class BaseConnectionPool(Pool): *connect_timeout* is the duration in seconds that the pool will wait before timing out on connect() to the database. If triggered, the - timeout will raise a ConnectionTimeout from get(). + timeout will raise a ConnectTimeout from get(). The remainder of the arguments are used as parameters to the *db_module*'s connection constructor. @@ -273,7 +273,7 @@ class SaranwrappedConnectionPool(BaseConnectionPool): """A pool which gives out saranwrapped database connections from a pool """ def create(self): - timer = api.exc_after(self.connect_timeout, ConnectionTimeout()) + timer = api.exc_after(self.connect_timeout, ConnectTimeout()) try: from eventlet import saranwrap return saranwrap.wrap(self._db_module).connect(*self._args, @@ -285,7 +285,7 @@ class TpooledConnectionPool(BaseConnectionPool): """A pool which gives out tpool.Proxy-based database connections from a pool. """ def create(self): - timer = api.exc_after(self.connect_timeout, ConnectionTimeout()) + timer = api.exc_after(self.connect_timeout, ConnectTimeout()) try: from eventlet import tpool try: @@ -293,9 +293,8 @@ class TpooledConnectionPool(BaseConnectionPool): autowrap = (self._db_module.cursors.DictCursor,) except: autowrap = () - return tpool.Proxy(self._db_module.connect(*self._args, - **self._kwargs), - autowrap=autowrap) + conn = tpool.execute(self._db_module.connect, *self._args, **self._kwargs) + return tpool.Proxy(conn, autowrap=autowrap) finally: timer.cancel() |
