]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
More Connection documentation.
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 12 Nov 2020 01:02:15 +0000 (01:02 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 12 Nov 2020 02:26:27 +0000 (02:26 +0000)
docs/connection.rst
psycopg3/psycopg3/connection.py

index 16067494fe72c619a6714af534947b90a209cff8..5ccb9f7a05ff8e15f0da4489ca88825765af3e6f 100644 (file)
@@ -69,7 +69,7 @@ Take a look to :ref:`transactions` for the details.
 
         TODO
 
-    .. rubric:: Methods you will need if you do something cool
+    .. rubric:: Methods you can use to do something cool
 
     .. automethod:: notifies
 
@@ -82,6 +82,12 @@ Take a look to :ref:`transactions` for the details.
 
     See :ref:`async-notify` for details.
 
+    .. automethod:: cancel
+    .. automethod:: add_notice_handler
+    .. automethod:: remove_notice_handler
+
+    TODO: document `Diagnostic`
+
 
 .. autoclass:: AsyncConnection
 
@@ -103,3 +109,4 @@ Take a look to :ref:`transactions` for the details.
 
 
 .. autoclass:: Notify
+    :members: channel, payload, pid
index 9ef0c9935972853ab584d43b82496b9dc94a150f..dd1b04f4524e6dc9647fd38ea2c6468630cd29db 100644 (file)
@@ -46,8 +46,13 @@ class Notify(NamedTuple):
     """An asynchronous notification received from the database."""
 
     channel: str
+    """The name of the channel on which the notification was received."""
+
     payload: str
+    """The message attached to the notification."""
+
     pid: int
+    """The PID of the backend process which sent the notification."""
 
 
 NoticeHandler = Callable[[e.Diagnostic], None]
@@ -138,13 +143,20 @@ class BaseConnection:
         raise NotImplementedError
 
     def cancel(self) -> None:
+        """Cancel the current operation on the connection."""
         c = self.pgconn.get_cancel()
         c.cancel()
 
     def add_notice_handler(self, callback: NoticeHandler) -> None:
+        """
+        Register a callable to be invoked when a notice message is received.
+        """
         self._notice_handlers.append(callback)
 
     def remove_notice_handler(self, callback: NoticeHandler) -> None:
+        """
+        Unregister a notice message callable previously registered.
+        """
         self._notice_handlers.remove(callback)
 
     @staticmethod