thieman / dagobah

Simple DAG-based job scheduler in Python
Do What The F*ck You Want To Public License
755 stars 160 forks source link

DagobahError: no independent nodes detected #150

Open zhenlongbai opened 9 years ago

zhenlongbai commented 9 years ago

Hi , I think I am a trouble.

When I add a job and make schedule ,but I did't add a task .There will be a issue .

I think the issue is associated with the code of /dagobah/core/dag.py.

all_nodes=dependent_nodes=0, then raise a exception . And the exception maybe refuse to EOF the thread . So that ,it will not start a thread .As a result , Dagobah maybe not update for next_run.

/dagobah/core/dag.py

def ind_nodes(self, graph):
    """ Returns a list of all nodes in the graph with no dependencies. """
    if graph is None:
        raise Exception("Graph given is None")
    all_nodes, dependent_nodes = set(graph.keys()), set()
    for downstream_nodes in graph.itervalues():
        [dependent_nodes.add(node) for node in downstream_nodes]
    return list(all_nodes - dependent_nodes)

def validate(self, graph=None):
    """ Returns (Boolean, message) of whether DAG is valid. """
    graph = graph if graph is not None else self.graph
    if   len(graph)!=0 and  len(self.ind_nodes(graph)) == 0:
        return (False, 'no independent nodes detected')
    try:
        self._topological_sort(graph)
    except ValueError:
        return (False, 'failed topological sort')
    return (True, 'valid')
zhenlongbai commented 9 years ago

// I think it maybe better to deal the exception . so that when a job broken, the others can work well

//dagobah/core/components.py def run(self): """ Continually monitors Jobs of the parent Dagobah. """ while not self.stopped: now = datetime.now() for job in self.parent.jobs: if not job.next_run: continue if job.next_run >= self.last_check and job.next_run <= now: if job.state.allow_start: try: job.start() except Exception , e : traceback.print_exc() else: job.next_run = job.cron_iter.get_next(datetime) self.last_checked = now time.sleep(1)

kakiezhang commented 9 years ago

yes, and there's another situation. if a job has been created(but the job task has not been set yet), the error will be showed in errorlog too when this job being activated by the scheduler at it's cron-time.