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: Deal with jobs resident in an engine that died.
docstr_tok: ["Deal","with","jobs","resident","in","an","engine","that","died","."]
code: def handle_stranded_tasks(self, engine):
      """Deal with jobs resident in an engine that died."""
      lost = self.pending[engine]
      for msg_id in list(lost.keys()):
          if msg_id not in lost:
              # prevent double-handling of messages
              continue
  
          raw_msg = lost[msg_id].raw_msg
          idents, msg = self.session.feed_identities(
              raw_msg, copy=False
          )
          parent = self.session.unpack(msg[1].bytes)
          idents = [engine, idents[0]]
  
          # build fake error reply
          try:
              raise error.EngineError(
                  f"Engine {engine!r} died while running task {msg_id!r}"
              )
          except:
              content = error.wrap_exception()
          # build fake metadata
          md = dict(
              status="error",
              engine=engine.decode("ascii"),
              date=util.utcnow(),
          )
          msg = self.session.msg(
              "apply_reply", content, parent=parent, metadata=md
          )
          raw_reply = list(
              map(
                  zmq.Message, self.session.serialize(msg, ident=idents)
              )
          )
          # and dispatch it
          self.dispatch_result(raw_reply)
  
      # finally scrub completed/failed lists
      self.completed.pop(engine)
      self.failed.pop(engine)
  
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 9 for calling the TaskScheduler obj's underlying member method code with example usage: obj.handle_stranded_tasks(engine) without return types