blob: 937833fcddcff263a1c07e0cc9d8ff743574c3c4 (
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 True:
publish(n)
time.sleep(3)
n += 1
|