美文网首页
python 异步 订阅/发布 redis 设置超时时间

python 异步 订阅/发布 redis 设置超时时间

作者: Tofookie | 来源:发表于2017-12-19 15:09 被阅读0次

    代码:

    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)
    
    

    相关文章

      网友评论

          本文标题:python 异步 订阅/发布 redis 设置超时时间

          本文链接:https://www.haomeiwen.com/subject/htabwxtx.html