예제 #1
0
def cached_engine(cache=[]):
    """ Returns a cached version, for internal usage """
    if not cache:
        # used persistent default argument as cache
        e = gs.engine()
        cache.append(e)
        return e
    return cache[0]
예제 #2
0
def worker(args):
    # Change job into error state in case of any exception
    gs.active_engine = gs.engine().get_used_engine(args.engine)
    try:
        worker_helper(args)
    except Exception:
        task_id = gs.active_engine.get_task_id(args.task_id)
        error_file = "%s.%s.%i" % (args.jobdir + os.path.sep + gs.STATE_ERROR,
                                   args.task_name, task_id)
        if not os.path.isfile(error_file) and not os.path.isdir(error_file):
            # create error file
            with open(error_file, 'w'):
                pass
        raise
예제 #3
0
def worker(args):
    # Change job into error state in case of any exception
    gs.active_engine = gs.engine().get_used_engine(args.engine)
    sisyphus.toolkit._sis_running_in_worker = True

    try:
        worker_helper(args)
    except Exception:
        task_id = gs.active_engine.get_task_id(args.task_id)
        error_file = "%s.%s.%i" % (args.jobdir + os.path.sep + gs.STATE_ERROR, args.task_name, task_id)
        log_file = "%s.%s.%i" % (args.jobdir + os.path.sep + gs.JOB_LOG, args.task_name, task_id)
        if not os.path.isfile(error_file) and not os.path.isdir(error_file):
            # create error file
            try:
                os.link(log_file, error_file)
            except OSError:
                if not os.path.isfile(error_file):
                    with open(error_file, 'w'):
                        pass
        raise
    finally:
        sisyphus.toolkit._sis_running_in_worker = False