Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/317847

Change subject: Die if no metrics received in one minute
......................................................................

Die if no metrics received in one minute

Change-Id: I3ad8bb49ceae76f2ae68ab0d67cf002b8db24a9e
---
M statsv.py
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/analytics/statsv 
refs/changes/47/317847/1

diff --git a/statsv.py b/statsv.py
index 0d17db0..30e6728 100644
--- a/statsv.py
+++ b/statsv.py
@@ -34,6 +34,7 @@
 from pykafka.common import OffsetType
 
 
+TIMEOUT = 60 * 1000
 logging.basicConfig(stream=sys.stderr, level=logging.INFO,
                     format='%(asctime)s %(message)s')
 supported_metric_types = ('c', 'g', 'ms')
@@ -82,7 +83,13 @@
     worker.start()
 
 topic = kafka.topics['statsv']
-consumer = topic.get_simple_consumer(auto_offset_reset=OffsetType.LATEST)
+consumer = topic.get_simple_consumer(
+        auto_offset_reset=OffsetType.LATEST,
+        consumer_timeout_ms=TIMEOUT)
 for message in consumer:
     if message is not None:
         queue.put(message.value)
+
+# If we reach this line, TIMEOUT elapsed with no events received.
+queue.close()
+raise RuntimeError('No messages received in %d seconds.' % TIMEOUT)

-- 
To view, visit https://gerrit.wikimedia.org/r/317847
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ad8bb49ceae76f2ae68ab0d67cf002b8db24a9e
Gerrit-PatchSet: 1
Gerrit-Project: analytics/statsv
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to