@@ -24,10 +24,6 @@ The `postgresql.notifyman.NotificationManager` class is used to wait for
2424messages to come in on a set of connections, pick up the messages, and deliver
2525the messages to the object's user via the `collections.Iterator` protocol.
2626
27- The notification manager is a simple event loop that services multiple
28- connections. In cases where only one connection needs to be serviced, the
29- `postgresql.api.Database.wait` method can be used to simplify the process.
30-
3127
3228Listening on a Single Connection
3329================================
@@ -149,8 +145,57 @@ However, doing so inside the loop is not a requirement; it is safe to remove a
149145connection from the set at any point.
150146
151147
148+ Notification Managers
149+ =====================
150+
151+ The `postgresql.notifyman.NotificationManager` is an event loop that services
152+ multiple connections. In cases where only one connection needs to be serviced,
153+ the `postgresql.api.Database.iternotifies` method can be used to simplify the
154+ process.
155+
156+
157+ Notification Manager Constructors
158+ ---------------------------------
159+
160+ ``NotificationManager(*connections, timeout = None)``
161+ Create a NotificationManager instance that manages the notifications coming
162+ from the given set of connections. The ``timeout`` keyword is optional and
163+ can be configured using the ``settimeout`` method as well.
164+
165+
166+ Notification Manager Interface Points
167+ -------------------------------------
168+
169+ ``NotificationManager.__iter__()``
170+ Returns the instance; it is an iterator.
171+
172+ ``NotificationManager.__next__()``
173+ Normally, yield the pair, connection and notifications list, when the next
174+ event is received. If a timeout is configured, `None` may be yielded to signal
175+ an idle event. The notifications list is a list of triples:
176+ ``(channel, payload, pid)``.
177+
178+ ``NotificationManager.settimeout(timeout : int)``
179+ Set the amount of time to wait before the manager yields an idle event.
180+ If zero, the manager will never wait and only yield notifications that are
181+ immediately available.
182+ If `None`, the manager will never emit idle events.
183+
184+ ``NotificationManager.gettimeout() -> [int, None]``
185+ Get the configured timeout; returns either `None`, or an `int`.
186+
187+ ``NotificationManager.connections``
188+ The set of connections that the manager is actively watching for
189+ notifications. Connections may be added or removed from the set at any time.
190+
191+ ``NotificationManager.garbage``
192+ The set of connections that failed. Normally empty, but when a connection gets
193+ an exceptional condition or explicitly raises an exception, it is removed from
194+ the ``connections`` set, and placed in ``garbage``.
195+
196+
152197Zero Timeout
153- ============
198+ ------------
154199
155200When a timeout of zero, ``0``, is configured, the notification manager will
156201terminate early. Specifically, each connection will be polled for any pending
@@ -175,7 +220,7 @@ losing any events.
175220
176221
177222Summary of Characteristics
178- ==========================
223+ --------------------------
179224
180225 * The iterator will continue until the connections die.
181226 * Objects yielded by the iterator are either `None`, an "idle event", or an
0 commit comments