Register a new subscriber and return its dedicated queue.
(self)
| 31 | self._subscribers: list[queue.Queue] = [] |
| 32 | |
| 33 | def subscribe(self) -> queue.Queue: |
| 34 | """Register a new subscriber and return its dedicated queue.""" |
| 35 | q: queue.Queue = queue.Queue(maxsize=_QUEUE_MAXSIZE) |
| 36 | with self._lock: |
| 37 | self._subscribers.append(q) |
| 38 | return q |
| 39 | |
| 40 | def unsubscribe(self, q: queue.Queue) -> None: |
| 41 | """Remove a subscriber queue (called when the HTTP connection closes).""" |