示例#1
0
  def __init__(self, buildPath, options, args):
    self.buildPath = buildPath
    self.options = options
    self.args = args
    self.cacheFolder = os.path.join(buildPath, '.ambuild2')
    self.dbpath = os.path.join(self.cacheFolder, 'graph')

    # This doesn't completely work yet because it's not communicated to child
    # processes. We'll have to send a message down or up to fix this.
    if self.options.no_color:
      util.DisableConsoleColors()

    with open(os.path.join(self.cacheFolder, 'vars'), 'rb') as fp:
      try:
        self.vars = util.pickle.load(fp)
      except ValueError as exn:
        sys.stderr.write('Build was configured with Python 3; use python3 instead.\n')
        sys.exit(1)
      except Exception as exn:
        if os.path.exists(os.path.join(self.cacheFolder, 'vars')):
          sys.stderr.write('There does not appear to be a build configured here.\n')
        else:
          sys.stderr.write('The build configured here looks corrupt; you will have to delete your objdir.\n')
        raise
        sys.exit(1)

    self.restore_environment()

    self.db = database.Database(self.dbpath)
    self.messagePump = MessagePump()
    self.procman = ProcessManager(self.messagePump)
    self.db.connect()
示例#2
0
文件: task.py 项目: xtfvje/ambuild
    def __init__(self, pump, channel, task_graph, vars, num_processes):
        super(TaskMasterChild, self).__init__(pump, channel)
        self.task_graph = task_graph
        self.outstanding = {}
        self.idle = set()
        self.build_failed = False
        self.build_completed = False
        self.messageMap = {
            'stop':
            lambda channel, message: self.receiveStop(channel, message)
        }

        self.procman = ProcessManager(pump)
        for i in range(num_processes):
            self.procman.spawn(WorkerParent(self), WorkerChild, args=(vars, ))

        self.channel.send({
            'id': 'spawned',
            'pid': os.getpid(),
            'type': 'taskmaster'
        })