Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly manage the lifetime of Exiters in Daemon Runs #7996

Merged
Prev Previous commit
Next Next commit
Create mixin to access the global exiter
  • Loading branch information
Borja Lorente committed Jul 25, 2019
commit d9529f8406a0a3cc2628a7d3170941cbfe7da10a
7 changes: 6 additions & 1 deletion src/python/pants/base/exception_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,13 @@ def reset_log_location(cls, new_log_location):
cls._pid_specific_error_fileobj = pid_specific_error_stream
cls._shared_error_fileobj = shared_error_stream

class AccessGlobalExiterMixin:
@property
def _exiter(self) -> Exiter:
return ExceptionSink._get_global_exiter()

@classmethod
def get_global_exiter(cls) -> Exiter:
def _get_global_exiter(cls) -> Exiter:
return cls._exiter

@classmethod
Expand Down
6 changes: 1 addition & 5 deletions src/python/pants/bin/daemon_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def exit_code(self):
return self._exit_code


class DaemonPantsRunner:
class DaemonPantsRunner(ExceptionSink.AccessGlobalExiterMixin):
"""A daemonizing PantsRunner that speaks the nailgun protocol to a remote client.

N.B. this class is primarily used by the PailgunService in pantsd.
Expand Down Expand Up @@ -142,10 +142,6 @@ def __init__(self, maybe_shutdown_socket, args, env, services, exit_code, schedu

self.exit_code = exit_code

@property
def _exiter(self) -> Exiter:
return ExceptionSink.get_global_exiter()

# TODO: this should probably no longer be necesary, remove.
def _make_identity(self):
"""Generate a ProcessManager identity for a given pants run.
Expand Down
6 changes: 1 addition & 5 deletions src/python/pants/bin/local_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def exit(self, result=PANTS_SUCCEEDED_EXIT_CODE, msg=None, *args, **kwargs):
super().exit(result=result, msg=msg, *args, **kwargs)


class LocalPantsRunner:
class LocalPantsRunner(ExceptionSink.AccessGlobalExiterMixin):
"""Handles a single pants invocation running in the process-local context."""

@staticmethod
Expand Down Expand Up @@ -230,10 +230,6 @@ def run(self):
maybe_profiled(self._profile_path):
self._run()

@property
def _exiter(self):
return ExceptionSink.get_global_exiter()

def _maybe_handle_help(self):
"""Handle requests for `help` information."""
if self._options.help_request:
Expand Down
6 changes: 1 addition & 5 deletions src/python/pants/bin/pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
logger = logging.getLogger(__name__)


class PantsRunner:
class PantsRunner(ExceptionSink.AccessGlobalExiterMixin):
"""A higher-level runner that delegates runs to either a LocalPantsRunner or RemotePantsRunner."""

def __init__(self, args=None, env=None, start_time=None):
Expand All @@ -35,10 +35,6 @@ def __init__(self, args=None, env=None, start_time=None):
def will_terminate_pantsd(self):
return not frozenset(self._args).isdisjoint(self._DAEMON_KILLING_GOALS)

@property
def _exiter(self):
return ExceptionSink.get_global_exiter()

def _enable_rust_logging(self, global_bootstrap_options):
levelname = global_bootstrap_options.level.upper()
init_rust_logger(levelname, global_bootstrap_options.log_show_rust_3rdparty)
Expand Down