blob: 722e80ea56df87ce142db33fa8304448c1cd8fb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import os, redis, json, time
from configure import REDIS_CHANNEL
def publish(number):
redis_host = os.getenv('REDIS_HOST', '127.0.0.1')
redis_password = os.getenv('REDIS_PASSWORD', '123456')
r = redis.Redis(host=redis_host, port=6379, password=redis_password, db=0)
r.publish(REDIS_CHANNEL, json.dumps({'filename':'a.txt', 'data':str(number)}))
n = 0
while n < 10:
publish(n)
time.sleep(2)
n += 1
|