Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2021 13:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AlvaroMonsalveSerrano/cf7c0cafa10cc846633a603dac50d699 to your computer and use it in GitHub Desktop.
Ejemplo de cliente consumidor a un broker de Redis
import redis
import logging
import json
from app_redis import config, exception
def start(redis_server: redis.Redis) -> None:
Get a message from Redis topic.
:param redis_server: redis.Redis
:return: None
""""[##] Consuming message...")
if redis_server is None:
raise exception.ConsumerRedisException()
consume_client_topic = redis_server.pubsub()
for message in consume_client_topic.listen():
if message['data'] != 1:
data = json.loads(message['data'].decode())"mesagge={data['message']} result={data['result']}")
def main():"## Consumer ##")
redis_server = redis.Redis(host=config.HOST_REDIS, port=config.PORT_REDIS, db=0)"[##] Redis connected")
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment