]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added PGconn.backend_pid
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 14 Mar 2020 12:07:02 +0000 (01:07 +1300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 14 Mar 2020 12:07:02 +0000 (01:07 +1300)
psycopg3/_pq_ctypes.py
psycopg3/pq_ctypes.py
tests/test_pq.py

index d0caa5f907aaf61bfa1b2d4953bc55883f2f3e33..6fcac518434612906b40ea10b4e692108b9eb7ba 100644 (file)
@@ -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
 
index 7aa0c7741c24cebfd73938d9ac471de10076f205..77448a2206c586f08a028cff44c3cfd5b6d8c9b9 100644 (file)
@@ -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
index 096660293066fbadb3dcc7c38457c837f41c5f8b..9a4e5a76c3128ac1906a2fe9e223a2bb6279a00b 100644 (file)
@@ -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?