def post_mortem_if_fail_for_main(main_func):

    def new_main_func(cfg, output_dir, *args, **kwargs):
        pdb_ = (MultiprocessingPdb(FolderLock(output_dir)) if (comm.get_world_size() > 1) else None)
        return post_mortem_if_fail(pdb_)(main_func)(cfg, output_dir, *args, **kwargs)
    return PicklableWrapper(new_main_func)
def post_mortem_if_fail_for_main(main_func):

    def new_main_func(cfg, output_dir, *args, **kwargs):
        pdb_ = (MultiprocessingPdb(FolderLock(output_dir)) if (comm.get_world_size() > 1) else None)
        return post_mortem_if_fail(pdb_)(main_func)(cfg, output_dir, *args, **kwargs)
    return PicklableWrapper(new_main_func)