class_docstr: Python TaskScheduler object.
  
  This is the simplest object that supports msg_id based
  DAG dependencies. *Only* task msg_ids are checked, not
  msg_ids of jobs submitted via the MUX queue.
class_docstr_tok: ["Python","TaskScheduler","object",".","This","is","the","simplest","object","that","supports","msg_id","based","DAG","dependencies",".","*","Only","*","task","msg_ids","are","checked",",","not","msg_ids","of","jobs","submitted","via","the","MUX","queue","."]
docstr: check location dependencies, and run if they are met.
docstr_tok: ["check","location","dependencies",",","and","run","if","they","are","met","."]
code: 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)
      available = self.available_engines()
      if not available:
          # 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 = list(filter(can_run, available))
  
          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.queue_map[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.queue_map[msg_id] = job
                      self.fail_unreachable(msg_id)
                      return False
              return False
      else:
          indices = None
  
      self.submit_task(job, indices)
      return True
  
imports: import time
  from collections import deque
  from random import randint, random
  from types import FunctionType
  import zmq
  from traitlets import Dict, Enum, Instance, Integer, List, observe
  from ipyparallel import Dependency, error, util
  from ipyparallel.controller.scheduler import Scheduler
label_desc: Use image node_id 14 for calling the TaskScheduler obj's underlying member method code with example usage: obj.maybe_run(job) and returns: True, False, job, False, False, False, False, False, False