def flush(self):
        while self.buffers:
            filename_list = self.buffers.keys()
            for filename in filename_list:
                out = '\n'.join(self.buffers[filename]) + '\n'
                mid_dirs = os.path.dirname(filename)
                try:
                    os.makedirs(mid_dirs)
                except __HOLE__, err:
                    if err.errno == errno.EEXIST:
                        pass
                    else:
                        raise
                try:
                    with lock_file(filename, append=True, unlink=False) as f:
                        f.write(out)
                except LockTimeout:
                    # couldn't write, we'll try again later
                    self.logger.debug(_('Timeout writing to %s' % filename))
                else:
                    del self.buffers[filename]
        self.total_size = 0
dataset/ETHPy150Open notmyname/slogging/slogging/file_buffer.py/FileBuffer.flush