Subscribe to channels. Channels supplied as keyword arguments expect a channel name as the key and a callable as the value. ``Subscription`` objects can also be supplied positionally with an optional handler. A channel's callable will be invoked autom
(
self, *args: ChannelT | Subscription, **kwargs: PubSubHandler
)
| 1370 | return self.execute_command("PUNSUBSCRIBE", *parsed_args) |
| 1371 | |
| 1372 | async def subscribe( |
| 1373 | self, *args: ChannelT | Subscription, **kwargs: PubSubHandler |
| 1374 | ) -> None: |
| 1375 | """ |
| 1376 | Subscribe to channels. |
| 1377 | Channels supplied as keyword arguments expect |
| 1378 | a channel name as the key and a callable as the value. |
| 1379 | ``Subscription`` objects can also be supplied positionally with an |
| 1380 | optional handler. |
| 1381 | A channel's callable will be invoked automatically |
| 1382 | when a message is received on that channel rather than producing a |
| 1383 | message via ``listen()`` or ``get_message()``. |
| 1384 | """ |
| 1385 | new_channels = parse_pubsub_subscriptions(args, kwargs) |
| 1386 | ret_val = await self.execute_command("SUBSCRIBE", *new_channels.keys()) |
| 1387 | # update the channels dict AFTER we send the command. we don't want to |
| 1388 | # subscribe twice to these channels, once for the command and again |
| 1389 | # for the reconnection. |
| 1390 | new_channels = self._normalize_keys(new_channels) |
| 1391 | self.channels.update(new_channels) |
| 1392 | self.pending_unsubscribe_channels.difference_update(new_channels) |
| 1393 | return ret_val |
| 1394 | |
| 1395 | def unsubscribe(self, *args) -> Awaitable: |
| 1396 | """ |
nothing calls this directly
no test coverage detected