Skip to content

Commit

Permalink
Fix RunTracker completion for help/no-goals/ctrl+c.
Browse files Browse the repository at this point in the history
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
  • Loading branch information
stuhood committed Mar 25, 2021
1 parent 986ad67 commit cf54749
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/python/pants/bin/local_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,27 @@ def _get_workunits_callbacks(self) -> Tuple[WorkunitsCallback, ...]:
)
return tuple(wcf.callback_factory() for wcf in workunits_callback_factories)

def run(self, start_time: float) -> ExitCode:
spec_parser = SpecsParser(get_buildroot())
specs = [str(spec_parser.parse_spec(spec)) for spec in self.options.specs]
self.run_tracker.start(run_start_time=start_time, specs=specs)
def _run_inner(self) -> ExitCode:
goals = tuple(self.options.goals)
if self.options.help_request:
return self._print_help(self.options.help_request)
if not goals:
return PANTS_SUCCEEDED_EXIT_CODE

try:
return self._perform_run(goals)
except Exception as e:
ExceptionSink.log_exception(e)
return PANTS_FAILED_EXIT_CODE
except KeyboardInterrupt:
return PANTS_FAILED_EXIT_CODE

def run(self, start_time: float) -> ExitCode:
with maybe_profiled(self.profile_path):
spec_parser = SpecsParser(get_buildroot())
specs = [str(spec_parser.parse_spec(spec)) for spec in self.options.specs]
self.run_tracker.start(run_start_time=start_time, specs=specs)
global_options = self.options.for_global_scope()
goals = tuple(self.options.goals)

streaming_reporter = StreamingWorkunitHandler(
self.graph_session.scheduler_session,
Expand All @@ -236,19 +249,12 @@ def run(self, start_time: float) -> ExitCode:
pantsd=global_options.pantsd,
)
with streaming_reporter:
if self.options.help_request:
return self._print_help(self.options.help_request)
if not goals:
return PANTS_SUCCEEDED_EXIT_CODE

engine_result = PANTS_FAILED_EXIT_CODE
try:
engine_result = self._perform_run(goals)
except Exception as e:
ExceptionSink.log_exception(e)
engine_result = PANTS_FAILED_EXIT_CODE

metrics = self.graph_session.scheduler_session.metrics()
self.run_tracker.set_pantsd_scheduler_metrics(metrics)
self.run_tracker.end_run(engine_result)
engine_result = self._run_inner()
finally:
metrics = self.graph_session.scheduler_session.metrics()
self.run_tracker.set_pantsd_scheduler_metrics(metrics)
self.run_tracker.end_run(engine_result)

return engine_result
return engine_result

0 comments on commit cf54749

Please sign in to comment.