TODO
- .. rubric:: Methods you will need if you do something cool
+ .. rubric:: Methods you can use to do something cool
.. automethod:: notifies
See :ref:`async-notify` for details.
+ .. automethod:: cancel
+ .. automethod:: add_notice_handler
+ .. automethod:: remove_notice_handler
+
+ TODO: document `Diagnostic`
+
.. autoclass:: AsyncConnection
.. autoclass:: Notify
+ :members: channel, payload, pid
"""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]
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