diff options
author | Lan Hui <lanhui@zjnu.edu.cn> | 2025-07-31 20:15:27 +0800 |
---|---|---|
committer | Lan Hui <lanhui@zjnu.edu.cn> | 2025-07-31 20:15:27 +0800 |
commit | 3d12f43570fd8f95cd0d0a716f002fbce888ddce (patch) | |
tree | 6258d6bdd3d72127e5f3dca210ee6a64fc1b95c4 /Code/test_redis_publish.py | |
parent | f6d8fd9133c387a1ec7938e028c1289322cf739e (diff) |
Test whether redis works
Diffstat (limited to 'Code/test_redis_publish.py')
-rw-r--r-- | Code/test_redis_publish.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Code/test_redis_publish.py b/Code/test_redis_publish.py new file mode 100644 index 0000000..b33ceed --- /dev/null +++ b/Code/test_redis_publish.py @@ -0,0 +1,13 @@ +import os, redis, json, time +from configure import REDIS_CHANNEL + +def publish(): + 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'})) + +while True: + publish() + time.sleep(3) + |