From: Daniele Varrazzo Date: Sat, 14 Mar 2020 12:07:02 +0000 (+1300) Subject: Added PGconn.backend_pid X-Git-Tag: 3.0.dev0~719 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66a5b6ff4cf086a8e6965f1979559358c2424da1;p=thirdparty%2Fpsycopg.git Added PGconn.backend_pid --- diff --git a/psycopg3/_pq_ctypes.py b/psycopg3/_pq_ctypes.py index d0caa5f90..6fcac5184 100644 --- a/psycopg3/_pq_ctypes.py +++ b/psycopg3/_pq_ctypes.py @@ -157,6 +157,10 @@ PQsocket = pq.PQsocket PQsocket.argtypes = [PGconn_ptr] PQsocket.restype = c_int +PQbackendPID = pq.PQbackendPID +PQbackendPID.argtypes = [PGconn_ptr] +PQbackendPID.restype = c_int + # 33.11. Miscellaneous Functions diff --git a/psycopg3/pq_ctypes.py b/psycopg3/pq_ctypes.py index 7aa0c7741..77448a220 100644 --- a/psycopg3/pq_ctypes.py +++ b/psycopg3/pq_ctypes.py @@ -189,6 +189,10 @@ class PGconn: def socket(self): return impl.PQsocket(self.pgconn_ptr) + @property + def backend_pid(self): + return impl.PQbackendPID(self.pgconn_ptr) + def _encode(self, s): if isinstance(s, bytes): return s diff --git a/tests/test_pq.py b/tests/test_pq.py index 096660293..9a4e5a76c 100644 --- a/tests/test_pq.py +++ b/tests/test_pq.py @@ -187,3 +187,7 @@ def test_protocol_version(pgconn): def test_server_version(pgconn): assert pgconn.server_version >= 90400 + + +def test_backend_pid(pgconn): + assert 2 <= pgconn.backend_pid <= 65535 # Unless increased in kernel?