代码:
pool = redis.ConnectionPool(host=REDIS_IP, port=REDIS_PORT, db=REDIS_DB, password=REDIS_PASSWORD)
rds = redis.StrictRedis(connection_pool=pool)
rds_sub = rds.pubsub()
rds_sub.subscribe('channel')
while True:
res = rds_sub.get_message(timeout=8)
if res and res['type'] == 'message':
print(res)
网友评论