'Checks if given task already exists in the Scheduler and both coincide
with their execution time
@param task: name of the task function
@param args: the job position arguments (list)
@param vars: the job named arguments (dict)'

def _duplicate_task_exists(self, task, args, vars):

    db = current.db
    ttable = db.scheduler_task
    _args = json.dumps(args)
    query = (((ttable.function_name == task) & (ttable.args == _args)) & ttable.status.belongs(['RUNNING', 'QUEUED', 'ALLOCATED']))
    jobs = db(query).select(ttable.vars)
    for job in jobs:
        job_vars = json.loads(job.vars)
        if (job_vars == vars):
            return True
    return False
