MCPcopy
hub / github.com/psycopg/psycopg / _maybe_close_connection

Method _maybe_close_connection

psycopg_pool/psycopg_pool/pool.py:361–372  ·  view source on GitHub ↗

Close a returned connection if necessary. Return `!True if the connection was closed.

(self, conn: CT)

Source from the content-addressed store, hash-verified

359 self._return_connection(conn, from_getconn=from_getconn)
360
361 def _maybe_close_connection(self, conn: CT) -> bool:
362 """Close a returned connection if necessary.
363
364 Return `!True if the connection was closed.
365 """
366 # If the pool is closed just close the connection instead of returning
367 # it to the pool. For extra refcare remove the pool reference from it.
368 if not self._closed:
369 return False
370
371 self._close_connection(conn)
372 return True
373
374 def open(self, wait: bool = False, timeout: float = 30.0) -> None:
375 """Open the pool by starting connecting and and accepting clients.

Callers 1

putconnMethod · 0.95

Calls 1

_close_connectionMethod · 0.95

Tested by

no test coverage detected