#!/usr/bin/env python # coding: utf-8 # In[1]: import os from functools import partial import ipyparallel as ipp # In[11]: cluster = ipp.Cluster(engines="mpi", n=4) def custom_error_message(launcher, stop_data): """log a custom error message when engines stop""" for line in launcher.get_output().splitlines(): if 'EXIT CODE:' in line: print("!!!!!!!!!!!!!Looks like your engine existed with:", line.split(":", 1)[1]) with cluster as rc: cluster.engine_set.on_stop(partial(custom_error_message, cluster.engine_set)) rc[0].apply_sync(os._exit, -1) # In[ ]: