Skip to content

Commit 43517c9

Browse files
committed
log launcher output at warning-level in case of nonzero exit code
more likely to see errors in case of failed start
1 parent ae1191b commit 43517c9

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ipyparallel/cluster/launcher.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,12 @@ def _log_output(self, stop_data=None):
327327
output = self.get_output(remove=True)
328328
if self.output_limit:
329329
output = "".join(output.splitlines(True)[-self.output_limit :])
330+
331+
log = self.log.debug
332+
if stop_data and stop_data.get("exit_code", 0) != 0:
333+
log = self.log.warning
330334
if output:
331-
self.log.debug(f"Output for {self.identifier}:\n{output}")
335+
log("Output for %s:\n%s", self.identifier, output)
332336

333337

334338
class ControllerLauncher(BaseLauncher):
@@ -794,6 +798,11 @@ def _notice_engine_stopped(self, data):
794798

795799
self.notify_stop(self.stop_data)
796800

801+
def _log_output(self, stop_data=None):
802+
# avoid double-logging output, already logged by each engine
803+
# that will be a lot if all 100 engines fail!
804+
pass
805+
797806
def get_output(self, remove=False):
798807
"""Get the output of all my child Launchers"""
799808
for identifier, launcher in self.launchers.items():
@@ -866,9 +875,13 @@ def start(self, n=1):
866875

867876
def _log_output(self, stop_data):
868877
"""Try to log mpiexec error output, if any, at warning level"""
869-
super()._log_output()
870-
if self.log.getEffectiveLevel() <= logging.DEBUG:
878+
super()._log_output(stop_data)
879+
880+
if stop_data and self.stop_data.get("exit_code", 0) != 0:
881+
# if this is True, super()._log_output would have already logged the full output
882+
# no need to extract from MPI
871883
return
884+
872885
output = self.get_output(remove=False)
873886
mpiexec_lines = []
874887

0 commit comments

Comments
 (0)