def maybe_run(self, job):
msg_id = job.msg_id<EOL>self.log.debug("<STR_LIT>", msg_id)<EOL>if not self.targets:<EOL><INDENT>return False<EOL><DEDENT>if job.follow or job.targets or job.blacklist or self.hwm:<EOL><INDENT>def can_run(idx):<EOL><INDENT>if self.hwm and self.loads[idx] == self.hwm:<EOL><INDENT>return False<EOL><DEDENT>target = self.targets[idx]<EOL>if target in job.blacklist:<EOL><INDENT>return False<EOL><DEDENT>if job.targets and target not in job.targets:<EOL><INDENT>return False<EOL><DEDENT>return job.follow.check(self.completed[target], self.failed[target])<EOL><DEDENT>indices = filter(can_run, range(len(self.targets)))<EOL>if not indices:<EOL><INDENT>if job.follow.all:<EOL><INDENT>dests = set()<EOL>relevant = set()<EOL>if job.follow.success:<EOL><INDENT>relevant = self.all_completed<EOL><DEDENT>if job.follow.failure:<EOL><INDENT>relevant = relevant.union(self.all_failed)<EOL><DEDENT>for m in job.follow.intersection(relevant):<EOL><INDENT>dests.add(self.destinations[m])<EOL><DEDENT>if len(dests) > <NUM_LIT:1>:<EOL><INDENT>self.depending[msg_id] = job<EOL>self.fail_unreachable(msg_id)<EOL>return False<EOL><DEDENT><DEDENT>if job.targets:<EOL><INDENT>job.targets.difference_update(job.blacklist)<EOL>if not job.targets or not job.targets.intersection(self.targets):<EOL><INDENT>self.depending[msg_id] = job<EOL>self.fail_unreachable(msg_id)<EOL>return False<EOL><DEDENT><DEDENT>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>indices = None<EOL><DEDENT>self.submit_task(job, indices)<EOL>return True<EOL>
check location dependencies, and run if they are met.