a1af2977c50399f58726182cd9481a6770c115ac,sos/sos_task.py,,check_task,#Any#,224

Before Change


                    else:
                        return "completed-old"
            else:
                if new_res:
                    env.logger.debug(res["exception"])
                    return "failed"
                else:
                    return "failed-old"
        except Exception as e:
            // sometimes the resfile is changed while we are reading it
            // so we wait a bit and try again.
            env.logger.warning(e)

After Change


        raise ValueError("Task does not exist: {}".format(task))
    status_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".status")
    res_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".res")
    job_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".sh")

    if os.path.isfile(res_file):
        try:
            from .target import FileTarget
            new_res = os.path.getmtime(task_file) <= os.path.getmtime(res_file)
            with open(res_file, "rb") as result:
                res = pickle.load(result)
            if res["succ"] == 0:
                if isinstance(res["output"], dict):
                    for x,y in res["output"].items():
                        if not FileTarget(x).exists() or FileTarget(x).signature() != y:
                            env.logger.debug("{} not found or signature mismatch".format(x))
                            return "result-mismatch"
                    // this is called "completed" remotely but will be
                    // translated to either completed or result-ready locally
                    return "completed"
                else:
                    return "completed"
            else:
                return "failed"
        except Exception as e:
            // sometimes the resfile is changed while we are reading it
            // so we wait a bit and try again.
            env.logger.warning(e)
            time.sleep(1)
            return check_task(task)
    try:
        if not os.path.isfile(status_file) or os.path.getmtime(status_file) < os.path.getmtime(task_file):
            if os.path.isfile(job_file) and os.path.getmtime(job_file) >= os.path.getmtime(task_file):
                return "submitted"
            else:
                return "pending"
    except Exception as e:
        // there is a slight chance that the old status_file is removed
        env.logger.warning(e)
        time.sleep(1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: vatlab/SoS
Commit Name: a1af2977c50399f58726182cd9481a6770c115ac
Time: 2017-03-30
Author: ben.bog@gmail.com
File Name: sos/sos_task.py
Class Name:
Method Name: check_task


Project Name: vatlab/SoS
Commit Name: ecb620b20567af3a5cbc1a29f8938335e66aa669
Time: 2017-04-08
Author: ben.bog@gmail.com
File Name: sos/sos_executor.py
Class Name: Base_Executor
Method Name: run


Project Name: vatlab/SoS
Commit Name: a1af2977c50399f58726182cd9481a6770c115ac
Time: 2017-03-30
Author: ben.bog@gmail.com
File Name: sos/sos_task.py
Class Name:
Method Name: check_task


Project Name: vatlab/SoS
Commit Name: 9e805c5f17d868a9d2a266e96600cfdbdee9dbfa
Time: 2017-04-07
Author: ben.bog@gmail.com
File Name: sos/sos_executor.py
Class Name: Base_Executor
Method Name: run