25 lines
567 B
Python
25 lines
567 B
Python
import time
|
|
|
|
from redis import StrictRedis
|
|
import json
|
|
|
|
rc = StrictRedis(host='localhost', port=6379, db=0)
|
|
ps = rc.pubsub()
|
|
ps.subscribe('jqr_msg')
|
|
|
|
msg_list = []
|
|
|
|
while True:
|
|
for item in ps.listen():
|
|
if item['type'] == 'message':
|
|
data = item.get('data')
|
|
print(data)
|
|
msg_list.append(data)
|
|
if len(msg_list) >= 10:
|
|
try:
|
|
time.sleep(1)
|
|
msg_list.clear()
|
|
except Exception as e:
|
|
print(e)
|
|
print(len(msg_list))
|