class_docstr: Base class which is used to run submissions.
class_docstr_tok: ["Base","class","which","is","used","to","run","submissions","."]
docstr: Runs docker command and enforces time limit.
  
  Args:
    cmd: list with the command line arguments which are passed to docker
      binary after run
    time_limit: time limit, in seconds. Negative value means no limit.
  
  Returns:
    how long it took to run submission in seconds
  
  Raises:
    WorkerError: if error occurred during execution of the submission
docstr_tok: ["Runs","docker","command","and","enforces","time","limit",".","Args",":","cmd",":","list","with","the","command","line","arguments","which","are","passed","to","docker","binary","after","run","time_limit",":","time","limit",",","in","seconds",".","Negative","value","means","no","limit",".","Returns",":","how","long","it","took","to","run","submission","in","seconds","Raises",":","WorkerError",":","if","error","occurred","during","execution","of","the","submission"]
code: def run_with_time_limit(self, cmd, time_limit=SUBMISSION_TIME_LIMIT):
      """Runs docker command and enforces time limit.
  
      Args:
        cmd: list with the command line arguments which are passed to docker
          binary after run
        time_limit: time limit, in seconds. Negative value means no limit.
  
      Returns:
        how long it took to run submission in seconds
  
      Raises:
        WorkerError: if error occurred during execution of the submission
      """
      if time_limit < 0:
          return self.run_without_time_limit(cmd)
      container_name = str(uuid.uuid4())
      cmd = [
          DOCKER_BINARY,
          "run",
          DOCKER_NVIDIA_RUNTIME,
          "--detach",
          "--name",
          container_name,
      ] + cmd
      logging.info("Docker command: %s", " ".join(cmd))
      logging.info("Time limit %d seconds", time_limit)
      retval = subprocess.call(cmd)
      start_time = time.time()
      elapsed_time_sec = 0
      while is_docker_still_running(container_name):
          elapsed_time_sec = int(time.time() - start_time)
          if elapsed_time_sec < time_limit:
              time.sleep(1)
          else:
              kill_docker_container(container_name)
              logging.warning(
                  "Submission was killed because run out of time"
              )
      logging.info("Elapsed time of submission: %d", elapsed_time_sec)
      logging.info("Docker retval: %d", retval)
      if retval != 0:
          logging.warning("Docker returned non-zero retval: %d", retval)
          raise WorkerError(
              "Docker returned non-zero retval " + str(retval)
          )
      return elapsed_time_sec
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from builtins import int
  import argparse
  import json
  import logging
  import os
  import random
  import shutil
  import subprocess
  import time
  import uuid
  from six import iteritems
  import eval_lib
  from cleverhans.utils import shell_call
label_desc: Use image node_id 5 for calling the ExecutableSubmission obj's underlying member method code with example usage: obj.run_with_time_limit(cmd, time_limit) and returns: elapsed_time_sec, self