def read(self, queue):
    try:
        res = self.redis.blpop(settings.CALLBACK_QUEUE, timeout=settings.JOB_EVENT_BUFFER_SECONDS)
        if (res is None):
            return {'event': 'FLUSH'}
        self.total += 1
        return json.loads(res[1])
    except redis.exceptions.RedisError:
        logger.exception('encountered an error communicating with redis')
        time.sleep(1)
    except (json.JSONDecodeError, KeyError):
        logger.exception('failed to decode JSON message from redis')
    finally:
        self.record_statistics()
    return {'event': 'FLUSH'}
def read(self, queue):
    try:
        res = self.redis.blpop(settings.CALLBACK_QUEUE, timeout=settings.JOB_EVENT_BUFFER_SECONDS)
        if (res is None):
            return {'event': 'FLUSH'}
        self.total += 1
        return json.loads(res[1])
    except redis.exceptions.RedisError:
        logger.exception('encountered an error communicating with redis')
        time.sleep(1)
    except (json.JSONDecodeError, KeyError):
        logger.exception('failed to decode JSON message from redis')
    finally:
        self.record_statistics()
    return {'event': 'FLUSH'}