changeset 1374:640c9e4de909

throttle collector's logging Ignore-this: 3ce1325041f3fa79450554b7bb75f55d
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 07 Jun 2016 10:53:05 +0000
parents ba6fd5eaa0cf
children ca5b10d7ecd1
files light9/collector/output.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/light9/collector/output.py	Tue Jun 07 10:52:31 2016 +0000
+++ b/light9/collector/output.py	Tue Jun 07 10:53:05 2016 +0000
@@ -1,6 +1,7 @@
 from __future__ import division
 from rdflib import URIRef
 import sys
+import time
 import usb.core
 import logging
 from twisted.internet import task
@@ -71,11 +72,15 @@
         from dmx import Dmx
         self.dev = Dmx(devicePath)
         self.currentBuffer = ''
+        self.lastLog = 0
         task.LoopingCall(self._loop).start(1 / 50)
 
     @stats.update.time()
     def update(self, values):
-        log.info('enttec %s', ' '.join(map(str, values)))
+        now = time.time()
+        if now > self.lastLog + 1:
+            log.info('enttec %s', ' '.join(map(str, values)))
+            self.lastLog = now
 
         # I was outputting on 76 and it was turning on the light at
         # dmx75. So I added the 0 byte. No notes explaining the footer byte.
@@ -97,6 +102,8 @@
         self.dev = Udmx()
         self.currentBuffer = ''
         self.lastSentBuffer = None
+        self.lastLog = 0
+
         # Doesn't actually need to get called repeatedly, but we do
         # need these two things:
         #   1. A throttle so we don't lag behind sending old updates.
@@ -107,7 +114,11 @@
 
     @stats.update.time()
     def update(self, values):
-        log.info('udmx %s', ' '.join(map(str, values)))
+        now = time.time()
+        if now > self.lastLog + 1:
+            log.info('udmx %s', ' '.join(map(str, values)))
+            self.lastLog = now
+
         self.currentBuffer = ''.join(map(chr, values))
     
     def _loop(self):