I want to use the Pub/Sub,  but I don't know how to pass the  parameter of callable function to the subscribe function, so that  the callable  function will be invoked automatically when a message is received on that channel.    (redis.__version__ == 3.3.11)

def subscribe(self, args, *kwargs): """ Subscribe to channels. Channels supplied as keyword arguments expect a channel name as the key and a callable as the value. 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(). """

Comment From: itamarhaber

Hello @Adhders

The answer is fully covered in redis-py's README at https://github.com/andymccurdy/redis-py#publish--subscribe - look for the paragraph starting with:

When a message is read on a channel or pattern with a message handler, the message dictionary is created and passed to the message handler. In this case, a None value is returned from get_message() since the message was already handled

Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. Questions should be directed to the community: