Skip to content

Commit de277e2

Browse files
committed
Use Queue nowait methods for better readability
1 parent 24f98df commit de277e2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: dbutils/pooled_pg.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def connection(self):
206206
if not self._connections.acquire(self._blocking):
207207
raise TooManyConnections
208208
try:
209-
con = self._cache.get(0)
209+
con = self._cache.get_nowait()
210210
except Empty:
211211
con = self.steady_connection()
212212
return PooledPgConnection(self, con)
@@ -222,7 +222,7 @@ def cache(self, con):
222222
con.rollback() # rollback a possible transaction
223223
except Exception:
224224
pass
225-
self._cache.put(con, 0) # and then put it back into the cache
225+
self._cache.put_nowait(con) # and then put it back into the cache
226226
except Full:
227227
con.close()
228228
if self._connections:
@@ -232,7 +232,7 @@ def close(self):
232232
"""Close all connections in the pool."""
233233
while 1:
234234
try:
235-
con = self._cache.get(0)
235+
con = self._cache.get_nowait()
236236
try:
237237
con.close()
238238
except Exception:

0 commit comments

Comments
 (0)