subscribe (client)

redis-py · realtime, pubsub-subscribe, channel-handlers, event-callbacks

Subscribes to Redis Pub/Sub channels with optional handler callbacks, updating internal state and triggering subscribed event on first subscription.

# Source: https://github.com/redis/redis-py | License: MIT | Copyright 2022-2023, Redis, inc
# Provided via justclaw.it.com; keep this notice with the code.
    def subscribe(
        self, *args: ChannelT | Subscription, **kwargs: PubSubHandler
    ) -> None:
        """
        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 automatically
        when a message is received on that channel rather than producing a
        message via ``listen()`` or ``get_message()``.
        """
        new_channels = parse_pubsub_subscriptions(args, kwargs)
        ret_v

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key