소스 검색

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']