Пример #1
0
    def new_workunit_under_parent(self, name, parent, labels=None, cmd=''):
        """Creates a (hierarchical) subunit of work for the purpose of timing and reporting.

    - name: A short name for this work. E.g., 'resolve', 'compile', 'scala', 'zinc'.
    - parent: The new workunit is created under this parent.
    - labels: An optional iterable of labels. The reporters can use this to decide how to
              display information about this work.
    - cmd: An optional longer string representing this work.
           E.g., the cmd line of a compiler invocation.

    Task code should not typically call this directly.
    """
        workunit = WorkUnit(run_tracker=self,
                            parent=parent,
                            name=name,
                            labels=labels,
                            cmd=cmd)
        workunit.start()
        try:
            self.report.start_workunit(workunit)
            yield workunit
        except KeyboardInterrupt:
            workunit.set_outcome(WorkUnit.ABORTED)
            self._aborted = True
            raise
        except:
            workunit.set_outcome(WorkUnit.FAILURE)
            raise
        else:
            workunit.set_outcome(WorkUnit.SUCCESS)
        finally:
            self.report.end_workunit(workunit)
            workunit.end()
Пример #2
0
 def get_background_root_workunit(self):
     if self._background_root_workunit is None:
         self._background_root_workunit = WorkUnit(run_tracker=self,
                                                   parent=None,
                                                   labels=[],
                                                   name='background',
                                                   cmd=None)
         self._background_root_workunit.start()
         self.report.start_workunit(self._background_root_workunit)
     return self._background_root_workunit
Пример #3
0
    def start(self, report):
        """Start tracking this pants run.

    report: an instance of pants.reporting.Report."""
        self.report = report
        self.report.open()

        self._main_root_workunit = WorkUnit(run_tracker=self,
                                            parent=None,
                                            labels=[],
                                            name=RunTracker.DEFAULT_ROOT_NAME,
                                            cmd=None)
        self.register_thread(self._main_root_workunit)
        self._main_root_workunit.start()
        self.report.start_workunit(self._main_root_workunit)