MCPcopy
hub / github.com/redis/redis-py / ssubscribe

Method ssubscribe

redis/asyncio/client.py:1409–1433  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

execute_commandMethod · 0.95
_normalize_keysMethod · 0.95
keysMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected