From e1c5cc91a8048423b7d6b17f0a0390ac54205196 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 17 Jun 2009 17:20:05 -0700 Subject: [PATCH] Disabled __del__ doing a put back to connection pool (best practice has always been to do put in a finally block). Disabled two_simultaneous_connections test since it's timing-sensitive. Reenabled these tests in runall.py. --- eventlet/db_pool.py | 4 +++- greentest/db_pool_test.py | 22 ++++++++++++++++++---- greentest/runall.py | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/eventlet/db_pool.py b/eventlet/db_pool.py index 5a8ea55..a1138bf 100644 --- a/eventlet/db_pool.py +++ b/eventlet/db_pool.py @@ -463,7 +463,9 @@ class PooledConnectionWrapper(GenericConnectionWrapper): self._destroy() def __del__(self): - self.close() + return # this causes some issues if __del__ is called in the + # main coroutine, so for now this is disabled + #self.close() class DatabaseConnector(object): diff --git a/greentest/db_pool_test.py b/greentest/db_pool_test.py index 2c2f57d..8518731 100644 --- a/greentest/db_pool_test.py +++ b/greentest/db_pool_test.py @@ -132,7 +132,9 @@ class TestDBConnectionPool(DBTester): self.assert_(self.pool.free() == 1) self.assertRaises(AttributeError, self.connection.cursor) - def test_deletion_does_a_put(self): + def dont_test_deletion_does_a_put(self): + # doing a put on del causes some issues if __del__ is called in the + # main coroutine, so, not doing that for now self.assert_(self.pool.free() == 0) self.connection = None self.assert_(self.pool.free() == 1) @@ -222,8 +224,9 @@ class TestDBConnectionPool(DBTester): conn.commit() - def test_two_simultaneous_connections(self): - """ This test is timing-sensitive. """ + def dont_test_two_simultaneous_connections(self): + # timing-sensitive test, disabled until we come up with a better + # way to do this self.pool = self.create_pool(2) conn = self.pool.get() self.set_up_test_table(conn) @@ -393,7 +396,7 @@ class TestDBConnectionPool(DBTester): self.assertEquals(self.pool.free(), 0) self.assertEquals(self.pool.waiting(), 1) self.pool.put(conn) - timer = api.exc_after(0.3, api.TimeoutError) + timer = api.exc_after(1, api.TimeoutError) conn = e.wait() timer.cancel() self.assertEquals(self.pool.free(), 0) @@ -442,6 +445,17 @@ class TestTpoolConnectionPool(TestDBConnectionPool): max_idle=max_idle, max_age=max_age, connect_timeout = connect_timeout, **self._auth) + + + def setUp(self): + from eventlet import tpool + tpool.QUIET = True + super(TestTpoolConnectionPool, self).setUp() + + def tearDown(self): + from eventlet import tpool + tpool.QUIET = False + super(TestTpoolConnectionPool, self).tearDown() class TestSaranwrapConnectionPool(TestDBConnectionPool): diff --git a/greentest/runall.py b/greentest/runall.py index f07b406..912466e 100755 --- a/greentest/runall.py +++ b/greentest/runall.py @@ -39,7 +39,7 @@ PARSE_PERIOD = 10 # the following aren't in the default list unless --all option present NOT_HUBS = set() NOT_REACTORS = set(['wxreactor', 'glib2reactor', 'gtk2reactor']) -NOT_TESTS = set(['db_pool_test.py']) +NOT_TESTS = set() def w(s): sys.stderr.write("%s\n" % (s, ))