Subscribes the client to the specified shard 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'
(
self,
*args: ChannelT | Subscription,
target_node: Any = None,
**kwargs: PubSubHandler,
)
| 1400 | return self.execute_command("UNSUBSCRIBE", *args) |
| 1401 | |
| 1402 | def ssubscribe( |
| 1403 | self, |
| 1404 | *args: ChannelT | Subscription, |
| 1405 | target_node: Any = None, |
| 1406 | **kwargs: PubSubHandler, |
| 1407 | ) -> None: |
| 1408 | """ |
| 1409 | Subscribes the client to the specified shard channels. |
| 1410 | Channels supplied as keyword arguments expect a channel name as the key |
| 1411 | and a callable as the value. |
| 1412 | ``Subscription`` objects can also be supplied positionally |
| 1413 | with an optional handler. |
| 1414 | A channel's callable will be invoked automatically when a message |
| 1415 | is received on that channel rather than producing a message |
| 1416 | via ``listen()`` or ``get_sharded_message()``. |
| 1417 | """ |
| 1418 | new_s_channels = parse_pubsub_subscriptions(args, kwargs) |
| 1419 | ret_val = self.execute_command("SSUBSCRIBE", *new_s_channels.keys()) |
| 1420 | # update the s_channels dict AFTER we send the command. we don't want to |
| 1421 | # subscribe twice to these channels, once for the command and again |
| 1422 | # for the reconnection. |
| 1423 | new_s_channels = self._normalize_keys(new_s_channels) |
| 1424 | self.shard_channels.update(new_s_channels) |
| 1425 | if not self.subscribed: |
| 1426 | # Set the subscribed_event flag to True |
| 1427 | self.subscribed_event.set() |
| 1428 | # Clear the health check counter |
| 1429 | self.health_check_response_counter = 0 |
| 1430 | self.pending_unsubscribe_shard_channels.difference_update(new_s_channels) |
| 1431 | return ret_val |
| 1432 | |
| 1433 | def sunsubscribe(self, *args, target_node=None): |
| 1434 | """ |