'A very poor implementation of tail, but it doesn\'t need to be fancy
since we are only searching the last 2K'

def __check_memory_limit(self, efile_path):

    try:
        log.debug('Checking    %s    for    exceeded    memory    message    from    SLURM', efile_path)
        with open(efile_path) as f:
            if (os.path.getsize(efile_path) > 2048):
                f.seek((-2048), os.SEEK_END)
                f.readline()
            for line in f.readlines():
                stripped_line = line.strip()
                if (stripped_line == SLURM_MEMORY_LIMIT_EXCEEDED_MSG):
                    return 'This    job    was    terminated    because    it    used    more    memory    than    it    was    allocated.'
                elif any(((_ in stripped_line) for _ in SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS)):
                    return 'This    job    was    cancelled    probably    because    it    used    more    memory    than    it    was    allocated.'
    except:
        log.exception('Error    reading    end    of    %s:', efile_path)
    return False
