summaryrefslogtreecommitdiff
path: root/test/engine/test_pool.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-12-27 14:10:36 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-12-27 14:10:36 -0500
commitf1a22596e2283371f2216245ac4b7ff9a0fb6a9a (patch)
tree8562df8283a74c13fea539ae90fae252c27a8ba0 /test/engine/test_pool.py
parent60e7034a7423955cd89d5624f8769d3804ca6d82 (diff)
downloadsqlalchemy-f1a22596e2283371f2216245ac4b7ff9a0fb6a9a.tar.gz
Note time passage requirement for pool.invalidate()
For Windows, time.time() may only have 16 millisecond accuracy, so invalidation routines which compare the time.time() of invalidate() to the time.time() when the ConnectionRecord last connected may fail in a unit test environment that does not pause at least this much time since the ConnectionRecord startup. Using >= for comparison instead of > was considered but this only leads to more confusing results as the ConnecitonRecord goes into a re-connect loop as time continues to not pass. Overall, while using routines such as Python 3.7's time_ns() might be helpful, for now make sure tests which rely on this are marked under timing intensive and add small sleeps. Change-Id: I1a7162e67912d22c135fa517b687a073f8fd9151
Diffstat (limited to 'test/engine/test_pool.py')
-rw-r--r--test/engine/test_pool.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index ced42c78d..31b893734 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -1217,11 +1217,16 @@ class QueuePoolTest(PoolTestBase):
is_(c2.connection, c_ref())
c2_rec = c2._connection_record
+
+ # ensure pool invalidate time will be later than starttime
+ # for ConnectionRecord objects above
+ time.sleep(0.1)
c2.invalidate(soft=True)
+
is_(c2_rec.connection, c2.connection)
c2.close()
- time.sleep(0.5)
+
c3 = p.connect()
is_not_(c3.connection, c_ref())
is_(c3._connection_record, c2_rec)
@@ -1285,6 +1290,7 @@ class QueuePoolTest(PoolTestBase):
time.sleep(1.5)
self._assert_cleanup_on_pooled_reconnect(dbapi, p)
+ @testing.requires.timing_intensive
def test_connect_handler_not_called_for_recycled(self):
"""test [ticket:3497]"""
@@ -1300,6 +1306,10 @@ class QueuePoolTest(PoolTestBase):
dbapi.shutdown(True)
+ # ensure pool invalidate time will be later than starttime
+ # for ConnectionRecord objects above
+ time.sleep(0.1)
+
bad = p.connect()
p._invalidate(bad)
bad.close()
@@ -1323,6 +1333,7 @@ class QueuePoolTest(PoolTestBase):
[call.connect(ANY, ANY), call.checkout(ANY, ANY, ANY)],
)
+ @testing.requires.timing_intensive
def test_connect_checkout_handler_always_gets_info(self):
"""test [ticket:3497]"""
@@ -1336,6 +1347,10 @@ class QueuePoolTest(PoolTestBase):
dbapi.shutdown(True)
+ # ensure pool invalidate time will be later than starttime
+ # for ConnectionRecord objects above
+ time.sleep(0.1)
+
bad = p.connect()
p._invalidate(bad)
bad.close()