rds_test.py 304 B

12345678910111213
  1. import redis
  2. import time
  3. r = redis.Redis(host='db.ptt.cx', port=6379, db=1)
  4. p = r.pubsub(ignore_subscribe_messages=True)
  5. p.subscribe('q_hhh_seo')
  6. while True:
  7. message = p.get_message()
  8. if message:
  9. print(message['data'].decode('utf-8'))
  10. time.sleep(0.001) # be nice to the system :)