| 372 | |
| 373 | @staticmethod |
| 374 | def _notify_handler( |
| 375 | wself: ReferenceType[BaseConnection[Row]], pgn: pq.PGnotify |
| 376 | ) -> None: |
| 377 | if not (self := wself()): |
| 378 | return |
| 379 | |
| 380 | enc = self.pgconn._encoding |
| 381 | n = Notify(pgn.relname.decode(enc), pgn.extra.decode(enc), pgn.be_pid) |
| 382 | |
| 383 | if self._notify_handlers: |
| 384 | for cb in self._notify_handlers: |
| 385 | cb(n) |
| 386 | else: |
| 387 | # `_notifies_backlog` is None if the `notifies()` generator is running |
| 388 | if (d := self._notifies_backlog) is not None: |
| 389 | d.append(n) |
| 390 | |
| 391 | @property |
| 392 | def prepare_threshold(self) -> int | None: |