diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-07 08:42:48 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-07 09:14:13 -0400 |
commit | 0220b58917b5a979891b5765f6ac5095e0368489 (patch) | |
tree | 2c914e75af50484b8e88603cfeab418e900fe4f2 /lib/sqlalchemy/util/compat.py | |
parent | fc643ae73009e91e2dcff9ef57fb7dc0e48df88b (diff) | |
download | sqlalchemy-0220b58917b5a979891b5765f6ac5095e0368489.tar.gz |
Use monotonic time for pool age measurement
The internal clock used by the :class:`_pool.Pool` object is now
time.monotonic_time() under Python 3. Under Python 2, time.time() is still
used, which is legacy. This clock is used to measure the age of a
connection against its starttime, and used in comparisons against the
pool_timeout setting as well as the last time the pool was marked as
invalid to determine if the connection should be recycled. Previously,
time.time() was used which was subject to inaccuracies as a result of
system clock changes as well as poor time resolution on windows.
Change-Id: I94f90044c1809508e26a5a00134981c2a00d0405
Diffstat (limited to 'lib/sqlalchemy/util/compat.py')
-rw-r--r-- | lib/sqlalchemy/util/compat.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index d3fefa526..b94ea353e 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -109,6 +109,8 @@ if py3k: from io import StringIO from itertools import zip_longest from time import perf_counter + from time import monotonic as monotonic_time + from urllib.parse import ( quote_plus, unquote_plus, @@ -207,6 +209,7 @@ else: from cStringIO import StringIO as byte_buffer # noqa from itertools import izip_longest as zip_longest # noqa from time import clock as perf_counter # noqa + from time import time as monotonic_time # noqa from urllib import quote # noqa from urllib import quote_plus # noqa from urllib import unquote # noqa |