class_docstr: Execute workflow with SGE/OGE/PBS like batch system
class_docstr_tok: ["Execute","workflow","with","SGE\/OGE\/PBS","like","batch","system"]
code: def _get_result(self, taskid):
      if taskid not in self._pending:
          raise Exception("Task %d not found" % taskid)
      if self._is_pending(taskid):
          return None
      node_dir = self._pending[taskid]
      # MIT HACK
      # on the pbs system at mit the parent node directory needs to be
      # accessed before internal directories become available. there
      # is a disconnect when the queueing engine knows a job is
      # finished to when the directories become statable.
      t = time()
      timeout = float(self._config["execution"]["job_finished_timeout"])
      timed_out = True
      while (time() - t) < timeout:
          try:
              glob(os.path.join(node_dir, "result_*.pklz")).pop()
              timed_out = False
              break
          except Exception as e:
              logger.debug(e)
          sleep(2)
      if timed_out:
          result_data = {
              "hostname": "unknown",
              "result": None,
              "traceback": None,
          }
          results_file = None
          try:
              error_message = (
                  "Job id ({}) finished or terminated, but "
                  "results file does not exist after ({}) "
                  "seconds. Batch dir contains crashdump file "
                  "if node raised an exception.\n"
                  "Node working directory: ({}) ".format(
                      taskid, timeout, node_dir
                  )
              )
              raise OSError(error_message)
          except OSError as e:
              result_data["traceback"] = "\n".join(
                  format_exception(*sys.exc_info())
              )
      else:
          results_file = glob(os.path.join(node_dir, "result_*.pklz"))[
              0
          ]
          result_data = load_resultfile(results_file)
      result_out = dict(result=None, traceback=None)
      if isinstance(result_data, dict):
          result_out["result"] = result_data["result"]
          result_out["traceback"] = result_data["traceback"]
          result_out["hostname"] = result_data["hostname"]
          if results_file:
              crash_file = os.path.join(node_dir, "crashstore.pklz")
              os.rename(results_file, crash_file)
      else:
          result_out["result"] = result_data
      return result_out
  
imports: import sys
  from copy import deepcopy
  from glob import glob
  import os
  import shutil
  from time import sleep, time
  from traceback import format_exception
  import numpy
  from ...None import logging
  from ...utils.misc import str2bool
  from ..engine.utils import topological_sort, load_resultfile
  from ..engine import MapNode
  from .tools import report_crash, report_nodes_not_run, create_pyscript
label_desc: Use image node_id 4 for calling the SGELikeBatchManagerBase obj's underlying member method code with example usage: obj._get_result(taskid) and returns: result_out, None