diff options
author | Lan Hui <lanhui@zjnu.edu.cn> | 2025-09-29 17:31:15 +0800 |
---|---|---|
committer | Lan Hui <lanhui@zjnu.edu.cn> | 2025-09-29 17:31:15 +0800 |
commit | e4190efc2efb8267a1dede57a6c75d34060ac68e (patch) | |
tree | a43758187480f85922dfe6b748516a8fe45bc86a /Code/test_redis_publish.py | |
parent | fb607b33ac1291d33164879a6232cad3f842d9e6 (diff) | |
parent | f57f6e3c256db8e160fdf40cbba51180803d3124 (diff) |
Merge branch 'master' of 118.25.96.118:~/BRAINCL
Diffstat (limited to 'Code/test_redis_publish.py')
-rw-r--r-- | Code/test_redis_publish.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Code/test_redis_publish.py b/Code/test_redis_publish.py index b33ceed..937833f 100644 --- a/Code/test_redis_publish.py +++ b/Code/test_redis_publish.py @@ -1,13 +1,14 @@ import os, redis, json, time from configure import REDIS_CHANNEL -def publish(): +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':'123'})) + r.publish(REDIS_CHANNEL, json.dumps({'filename':'a.txt', 'data':str(number)})) +n = 0 while True: - publish() + publish(n) time.sleep(3) - + n += 1 |