Skip to content

Commit 5e13f56

Browse files
authored
Merge pull request #866 from minrk/mpi-more-output
log launcher output at warning-level in case of nonzero exit code
2 parents 04d8a4f + 43517c9 commit 5e13f56

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
@@ -328,8 +328,12 @@ def _log_output(self, stop_data=None):
328328
output = self.get_output(remove=True)
329329
if self.output_limit:
330330
output = "".join(output.splitlines(True)[-self.output_limit :])
331+
332+
log = self.log.debug
333+
if stop_data and stop_data.get("exit_code", 0) != 0:
334+
log = self.log.warning
331335
if output:
332-
self.log.debug(f"Output for {self.identifier}:\n{output}")
336+
log("Output for %s:\n%s", self.identifier, output)
333337

334338

335339
class ControllerLauncher(BaseLauncher):
@@ -795,6 +799,11 @@ def _notice_engine_stopped(self, data):
795799

796800
self.notify_stop(self.stop_data)
797801

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

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

0 commit comments

Comments
 (0)