Describes points to note when using the Connection Manager using the Python language package (psycopg).
In the Python language package (psycopg), you can use the psycopg.Connection class and the psycopg.AsyncConnection class to work with the Connection Manager. If you want to use methods that are not defined in these two classes, also refer to "3.3 How to Use in libpq".
The Connection Manager's heartbeat monitoring feature cannot be used with the Python language package (psycopg). Therefore, if you want to perform the heartbeat monitoring with the Python language package (psycopg), use the TCP keepalive feature. However, the TCP keepalive feature has disadvantages, as listed in "1.1.1 Difference from TCP keepalive". Deal with this as follows.
Set the tcp_user_timeout parameter. Since the Python language package (psycopg) communicates using libpq, you can use the tcp_user_timeout parameter of libpq.
Set the value of TcpMaxDataRetransmissions in the registry (HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters). However, be careful about the value you set because it will affect the entire OS.
There is no workaround because the keepalive feature needs to be enabled. Therefore, be careful when using the Python language package (psycopg) directly.