summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/pool
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-01-03 21:49:49 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-01-03 21:49:49 +0000
commitc0352b03e840ddf68116182b22c5fd4eac2059cf (patch)
tree46c46a3d151197f149348680fcbbc18bdc395e81 /lib/sqlalchemy/pool
parent5881fd274015af3de37f2ff0f91ff6a7c61c1540 (diff)
parenta076b1f30406cbb59a55e2c01ddd17a84636778e (diff)
downloadsqlalchemy-c0352b03e840ddf68116182b22c5fd4eac2059cf.tar.gz
Merge "Use context managers for threading.Lock()"
Diffstat (limited to 'lib/sqlalchemy/pool')
-rw-r--r--lib/sqlalchemy/pool/dbapi_proxy.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/sqlalchemy/pool/dbapi_proxy.py b/lib/sqlalchemy/pool/dbapi_proxy.py
index 95f207906..6e11d2e59 100644
--- a/lib/sqlalchemy/pool/dbapi_proxy.py
+++ b/lib/sqlalchemy/pool/dbapi_proxy.py
@@ -104,8 +104,7 @@ class _DBProxy(object):
try:
return self.pools[key]
except KeyError:
- self._create_pool_mutex.acquire()
- try:
+ with self._create_pool_mutex:
if key not in self.pools:
kw.pop("sa_pool_key", None)
pool = self.poolclass(
@@ -115,8 +114,6 @@ class _DBProxy(object):
return pool
else:
return self.pools[key]
- finally:
- self._create_pool_mutex.release()
def connect(self, *args, **kw):
"""Activate a connection to the database.