Esempio n. 1
0
def eventStreamLastContributor():
    for msg in subscriber_lastContrib.listen():
        content = msg['data'].decode('utf8')
        contentJson = json.loads(content)
        lastContribJson = json.loads(contentJson['log'])
        org = lastContribJson['org']
        to_return = contributor_helper.getContributorFromRedis(org)
        epoch = lastContribJson['epoch']
        to_return['epoch'] = epoch
        yield 'data: {}\n\n'.format(json.dumps(to_return))
Esempio n. 2
0
def eventStreamLastContributor():
    subscriber_lastContrib = redis_server_log.pubsub(ignore_subscribe_messages=True)
    subscriber_lastContrib.psubscribe(cfg.get('RedisLog', 'channelLastContributor'))
    try:
        for msg in subscriber_lastContrib.listen():
            content = msg['data']
            contentJson = json.loads(content)
            lastContribJson = json.loads(contentJson['log'])
            org = lastContribJson['org']
            to_return = contributor_helper.getContributorFromRedis(org)
            epoch = lastContribJson['epoch']
            to_return['epoch'] = epoch
            yield 'data: {}\n\n'.format(json.dumps(to_return))
    except GeneratorExit:
        subscriber_lastContrib.unsubscribe()