Skip to content

Commit 3431bbe

Browse files
send an entire traceback to the rust logger (no clue why this works)
# 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]
1 parent 8902834 commit 3431bbe

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

src/python/pants/base/exception_sink.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ class ExceptionSink:
123123
# Set in methods on SignalHandler and exposed to the engine rust code.
124124
_signal_sent: Optional[int] = None
125125

126-
# Whether the rust logger has been initialized so we can stop doing extra work in this class.
127-
_logging_initialized: bool = False
128-
129126
def __new__(cls, *args, **kwargs):
130127
raise TypeError("Instances of {} are not allowed to be constructed!".format(cls.__name__))
131128

@@ -192,16 +189,6 @@ def reset_log_location(cls, new_log_location: str) -> None:
192189
cls._pid_specific_error_fileobj = pid_specific_error_stream
193190
cls._shared_error_fileobj = shared_error_stream
194191

195-
@classmethod
196-
def set_logging_initialized(cls):
197-
"""Set the flag (to True) which indicates that the rust logger has been initialized.
198-
199-
Class state:
200-
- Overwrites `cls._logging_initialized`.
201-
"""
202-
# NB: mutate the class variables!
203-
cls._logging_initialized = True
204-
205192
@classmethod
206193
def exceptions_log_path(cls, for_pid=None, in_dir=None):
207194
"""Get the path to either the shared or pid-specific fatal errors log file."""
@@ -384,15 +371,13 @@ def log_exception(cls, exc_class=None, exc=None, tb=None, add_newline=False):
384371
extra_err_msg = "Additional error logging unhandled exception {}: {}".format(exc, e)
385372
logger.error(extra_err_msg)
386373

387-
# The rust logger implementation is used for most of pants's execution, but at import time,
388-
# we want to be able to see any stacktrace to know where the error is being raised.
389-
if cls._logging_initialized:
390-
logger.exception(exc)
391-
else:
392-
exception_log_entry = cls._format_unhandled_exception_log(
393-
exc, tb, add_newline, should_print_backtrace=True
394-
)
395-
logger.error(exception_log_entry)
374+
# The rust logger implementation will have its own stacktrace, but at import time, we want
375+
# to be able to see any stacktrace to know where the error is being raised, so we reproduce
376+
# it here.
377+
exception_log_entry = cls._format_unhandled_exception_log(
378+
exc, tb, add_newline, should_print_backtrace=True
379+
)
380+
logger.exception(exception_log_entry)
396381

397382
@classmethod
398383
def _handle_signal_gracefully(cls, signum, signame, traceback_lines):

src/python/pants/bin/pants_runner.py

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def run(self, start_time: float) -> ExitCode:
7575
# We enable logging here, and everything before it will be routed through regular
7676
# Python logging.
7777
setup_logging(global_bootstrap_options, stderr_logging=True)
78-
ExceptionSink.set_logging_initialized()
7978

8079
if self._should_run_with_pantsd(global_bootstrap_options):
8180
try:

0 commit comments

Comments
 (0)