Ejemplo n.º 1
0
def _GetMasterInfo():
    """Retrieve the job id from the master process

  This also closes standard input/output

  @rtype: int

  """
    logging.debug("Reading job id from the master process")
    logging.debug("Opening transport over stdin/out")
    with contextlib.closing(transport.FdTransport((0, 1))) as trans:
        job_id = int(trans.Call(""))
        logging.debug("Got job id %d", job_id)
    return job_id
Ejemplo n.º 2
0
def _GetMasterInfo():
  """Retrieves the job id and lock file name from the master process

  This also closes standard input/output

  """
  logging.debug("Opening transport over stdin/out")
  with contextlib.closing(transport.FdTransport((0, 1))) as trans:
    logging.debug("Reading job id from the master process")
    job_id = int(trans.Call(""))
    logging.debug("Got job id %d", job_id)
    logging.debug("Reading the livelock name from the master process")
    livelock_name = livelock.LiveLockName(trans.Call(""))
    logging.debug("Got livelock %s", livelock_name)
  return (job_id, livelock_name)
Ejemplo n.º 3
0
def _GetMasterInfo():
    """Retrieve job id, lock file name and secret params from the master process

  This also closes standard input/output

  @rtype: (int, string, json encoding of a list of dicts)

  """
    logging.debug("Opening transport over stdin/out")
    with contextlib.closing(transport.FdTransport((0, 1))) as trans:
        logging.debug("Reading job id from the master process")
        job_id = int(trans.Call(""))
        logging.debug("Got job id %d", job_id)
        logging.debug("Reading the livelock name from the master process")
        livelock_name = livelock.LiveLockName(trans.Call(""))
        logging.debug("Got livelock %s", livelock_name)
        logging.debug("Reading secret parameters from the master process")
        secret_params = trans.Call("")
        logging.debug("Got secret parameters.")
    return (job_id, livelock_name, secret_params)
Ejemplo n.º 4
0
def _SetupJob():
  """Setup the process to execute the job

  Retrieve the job id from argv, create a livelock and pass it to the master
  process and finally obtain any secret parameters.

  This also closes standard input/output.

  @rtype: (int, string, json encoding of a list of dicts)

  """
  job_id = int(sys.argv[1])
  ts = time.time()
  llock = livelock.LiveLock("job_%06d" % job_id)
  logging.debug("Opening transport over stdin/out")
  with contextlib.closing(transport.FdTransport((0, 1))) as trans:
    logging.debug("Sending livelock name to master")
    trans.Call(llock.GetPath()) # pylint: disable=E1101
    logging.debug("Reading secret parameters from the master process")
    secret_params = trans.Call("") # pylint: disable=E1101
    logging.debug("Got secret parameters.")
  return (job_id, llock, secret_params)