Exemplo n.º 1
0
    def setup_reporter(self, cfg=None):

        if self.__broker is None:
            self.setup_broker(cfg)

        self.__reporter = EventReporter(self.__broker)
Exemplo n.º 2
0
 def setUp(self):
     self.conn = WithRedis.StrictRedis()
     self.conn.flushdb()
     # override with your own UA to verify test results in GA
     self.my_ua = os.getenv('UA_ID', 'UA-116198943-3')
     self.er = EventReporter(UA=self.my_ua, conn=self.conn)
Exemplo n.º 3
0
import time
import json
import logging
import os
from redis import StrictRedis
from event_reporter import EventReporter

logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
LOG = logging.getLogger('evrlistener')

LOCALCONN = StrictRedis()
ER = EventReporter(conn=LOCALCONN)

def process_item(item):
    '''called for each new item'''
    return ER.dispatch(item)

def fetch_func():
    item = ER.fetch_oldest(blocking=False)
    if item:
        try:
            process_item(item)
        except Exception as e:
            LOG.error("process_item failed:{}, item: {}".format(
                e, item))
            time.sleep(10)  # sleep for 10 seconds
    time.sleep(0.001)  # be nice to the system :)


def main():
    while True: