浏览代码

handle bad stuff

Chris Mague 5 年之前
父节点
当前提交
e7b07cf435
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      StreamReader/runner.py

+ 9 - 2
StreamReader/runner.py

@@ -4,7 +4,7 @@ from redistimeseries.client import Client as RedisTimeSeries
 import redis
 import time
 
-redis_host = "localhost"
+redis_host = "redis"
 redis_port = 6379
 
 rts = RedisTimeSeries(host=redis_host, port=redis_port)
@@ -21,7 +21,14 @@ except:
     print("group already exists")
 
 while True:
-    msgs = r.xreadgroup("consumerGroup", "consumerName", streams={"mystream": '>'}, count=10, block=1000, noack=False)
+    # Retry 
+    try:
+        msgs = r.xreadgroup("consumerGroup", "consumerName", streams={"mystream": '>'}, count=10, block=1000, noack=False)
+    except:
+        print("Could not create readgroup")
+        time.sleep(5)
+        continue
+
     for msg in msgs:
         for m in msg[1]:
             evnt = m[1]['event_type']