def write_data_csv(self):
    self.connect_redis()
    [fn, rdk] = [self.Config.get(item) for item in ['FileName', 'RedisOutputKey']]
    error_count = 100
    while True:
        try:
            if (self.RedisConnection.llen(rdk) > 0):
                data = json.loads(self.RedisConnection.rpop(rdk).decode('utf8'))
                dt = datetime.datetime.fromtimestamp((data[1] / 1000), TIMEZONE)
                calendar_path = ('%4d/%02d/%02d' % (dt.year, dt.month, dt.day))
                with open(('%s/%s/%s' % (HOME_PATH, calendar_path, fn)), 'a+') as csvFile:
                    csvwriter = csv.writer(csvFile)
                    csvwriter.writerow(data)
            else:
                time.sleep(60)
        except RuntimeWarning:
            break
        except Exception as e:
            self.Logger.exception(e)
            error_count -= 1
            if (error_count < 0):
                break
def write_data_csv(self):
    self.connect_redis()
    [fn, rdk] = [self.Config.get(item) for item in ['FileName', 'RedisOutputKey']]
    error_count = 100
    while True:
        try:
            if (self.RedisConnection.llen(rdk) > 0):
                data = json.loads(self.RedisConnection.rpop(rdk).decode('utf8'))
                dt = datetime.datetime.fromtimestamp((data[1] / 1000), TIMEZONE)
                calendar_path = ('%4d/%02d/%02d' % (dt.year, dt.month, dt.day))
                with open(('%s/%s/%s' % (HOME_PATH, calendar_path, fn)), 'a+') as csvFile:
                    csvwriter = csv.writer(csvFile)
                    csvwriter.writerow(data)
            else:
                time.sleep(60)
        except RuntimeWarning:
            break
        except Exception as e:
            self.Logger.exception(e)
            error_count -= 1
            if (error_count < 0):
                break