MCPcopy
hub / github.com/psycopg/psycopg / check_connection

Method check_connection

psycopg_pool/psycopg_pool/pool.py:549–566  ·  view source on GitHub ↗

A simple check to verify that a connection is still working. Return quietly if the connection is still working, otherwise raise an exception. Used internally by `check()`, but also available for client usage, for instance as `!check` callback when a pool is

(conn: CT)

Source from the content-addressed store, hash-verified

547
548 @staticmethod
549 def check_connection(conn: CT) -> None:
550 """
551 A simple check to verify that a connection is still working.
552
553 Return quietly if the connection is still working, otherwise raise
554 an exception.
555
556 Used internally by `check()`, but also available for client usage,
557 for instance as `!check` callback when a pool is created.
558 """
559 if conn.autocommit:
560 conn.execute("")
561 else:
562 conn.autocommit = True
563 try:
564 conn.execute("")
565 finally:
566 conn.autocommit = False
567
568 def reconnect_failed(self) -> None:
569 """

Callers 4

checkMethod · 0.95
test_check_connectionFunction · 0.45
checkFunction · 0.45
test_check_connectionFunction · 0.45

Calls 1

executeMethod · 0.45

Tested by 3

test_check_connectionFunction · 0.36
checkFunction · 0.36
test_check_connectionFunction · 0.36