environment/lib/python2.7/site-packages/IPython/parallel/controller/scheduler.py
def maybe_run(self, job):
        """check location dependencies, and run if they are met."""
        msg_id = job.msg_id
        self.log.debug("Attempting to assign task %s", msg_id)
        if not self.targets:
            # no engines, definitely can't run
            return False
        
        if job.follow or job.targets or job.blacklist or self.hwm:
            # we need a can_run filter
            def can_run(idx):
                # check hwm
                if self.hwm and self.loads[idx] == self.hwm:
                    return False
                target = self.targets[idx]
                # check blacklist
                if target in job.blacklist:
                    return False
                # check targets
                if job.targets and target not in job.targets:
                    return False
                # check follow
                return job.follow.check(self.completed[target], self.failed[target])

            indices = filter(can_run, range(len(self.targets)))

            if not indices:
                # couldn't run
                if job.follow.all:
                    # check follow for impossibility
                    dests = set()
                    relevant = set()
                    if job.follow.success:
                        relevant = self.all_completed
                    if job.follow.failure:
                        relevant = relevant.union(self.all_failed)
                    for m in job.follow.intersection(relevant):
                        dests.add(self.destinations[m])
                    if len(dests) > 1:
                        self.depending[msg_id] = job
                        self.fail_unreachable(msg_id)
                        return False
                if job.targets:
                    # check blacklist+targets for impossibility
                    job.targets.difference_update(job.blacklist)
                    if not job.targets or not job.targets.intersection(self.targets):
                        self.depending[msg_id] = job
                        self.fail_unreachable(msg_id)
                        return False
                return False
        else:
            indices = None

        self.submit_task(job, indices)
        return True
def maybe_run(self, job):
        """check location dependencies, and run if they are met."""
        msg_id = job.msg_id
        self.log.debug("Attempting to assign task %s", msg_id)
        if not self.targets:
            # no engines, definitely can't run
            return False
        
        if job.follow or job.targets or job.blacklist or self.hwm:
            # we need a can_run filter
            def can_run(idx):
                # check hwm
                if self.hwm and self.loads[idx] == self.hwm:
                    return False
                target = self.targets[idx]
                # check blacklist
                if target in job.blacklist:
                    return False
                # check targets
                if job.targets and target not in job.targets:
                    return False
                # check follow
                return job.follow.check(self.completed[target], self.failed[target])

            indices = filter(can_run, range(len(self.targets)))

            if not indices:
                # couldn't run
                if job.follow.all:
                    # check follow for impossibility
                    dests = set()
                    relevant = set()
                    if job.follow.success:
                        relevant = self.all_completed
                    if job.follow.failure:
                        relevant = relevant.union(self.all_failed)
                    for m in job.follow.intersection(relevant):
                        dests.add(self.destinations[m])
                    if len(dests) > 1:
                        self.depending[msg_id] = job
                        self.fail_unreachable(msg_id)
                        return False
                if job.targets:
                    # check blacklist+targets for impossibility
                    job.targets.difference_update(job.blacklist)
                    if not job.targets or not job.targets.intersection(self.targets):
                        self.depending[msg_id] = job
                        self.fail_unreachable(msg_id)
                        return False
                return False
        else:
            indices = None

        self.submit_task(job, indices)
        return True
def maybe_run ( self , job ) : msg_id = job . msg_id self . log . debug ( "Attempting to assign task %s" , msg_id ) if not self . targets : # no engines, definitely can't run return False if job . follow or job . targets or job . blacklist or self . hwm : # we need a can_run filter def can_run ( idx ) : # check hwm if self . hwm and self . loads [ idx ] == self . hwm : return False target = self . targets [ idx ] # check blacklist if target in job . blacklist : return False # check targets if job . targets and target not in job . targets : return False # check follow return job . follow . check ( self . completed [ target ] , self . failed [ target ] ) indices = filter ( can_run , range ( len ( self . targets ) ) ) if not indices : # couldn't run if job . follow . all : # check follow for impossibility dests = set ( ) relevant = set ( ) if job . follow . success : relevant = self . all_completed if job . follow . failure : relevant = relevant . union ( self . all_failed ) for m in job . follow . intersection ( relevant ) : dests . add ( self . destinations [ m ] ) if len ( dests ) > 1 : self . depending [ msg_id ] = job self . fail_unreachable ( msg_id ) return False if job . targets : # check blacklist+targets for impossibility job . targets . difference_update ( job . blacklist ) if not job . targets or not job . targets . intersection ( self . targets ) : self . depending [ msg_id ] = job self . fail_unreachable ( msg_id ) return False return False else : indices = None self . submit_task ( job , indices ) return True
check location dependencies, and run if they are met.
check location dependencies and run if they are met .