def check_for_timeout(redis, jobid):
    """checks to see if a job has been running more than JOB_RUN_TIMEOUT seconds and sets it to STAT_CODE_TIMEOUT and sets keys to expire"""
    try:
        start_time = int(redis.get("%s-start_time" % jobid))
    except Exception:
        start_time = int(time.time()) - (JOB_RUN_TIMEOUT + 1)
    # logger.debug("Dalton in check_for_timeout(): job %s start time: %d" % (jobid, start_time))
    if not start_time or ((int(time.time()) - start_time) > JOB_RUN_TIMEOUT):
        if int(get_job_status(redis, jobid)) == STAT_CODE_RUNNING:
            logger.info(
                "Dalton in check_for_timeout(): job %s timed out.  Start time: %d, now: %d"
                % (jobid, start_time, int(time.time()))
            )
            set_job_status(redis, jobid, STAT_CODE_TIMEOUT)
            set_job_status_msg(
                redis,
                jobid,
                "Job %s has timed out, please try submitting the job again." % jobid,
            )
            set_keys_timeout(redis, jobid)
            return True
        else:
            return False
    else:
        return False
checks to see if a job has been running more than JOB_RUN_TIMEOUT seconds and sets it to STAT_CODE_TIMEOUT and sets keys to expire
app/dalton.py