pgcom.listener.Listener.poll

Listener.poll(channel: str, on_notify: Optional[Callable[[str], None]] = None, on_timeout: Optional[Callable] = None, on_close: Optional[Callable] = None, on_error: Optional[Callable[[Exception], None]] = None, timeout: int = 5) None[source]

Listen to the channel and activate callbacks on the notification.

This function sleeps until awakened when there is some data to read on the connection.

Parameters
  • channel – Name of the notification channel.

  • on_notify – Callback to be executed when the notification has arrived.

  • on_timeout – Callback to be executed by timeout.

  • on_close – Callback to be executed when connection is closed.

  • on_error – Callback to be executed if error occurs.

  • timeout – Timeout in seconds.