def _write_state_file(dst_dir, root, name, logger, observer):
    """ Write state of `root` and its children. Returns (filename, path). """
    state_name = name+'.pickle'
    state_path = os.path.join(dst_dir, state_name)
    try:
        save(root, state_path, SAVE_CPICKLE, -1, logger)
    except Exception as exc:
        msg = "Can't save to '%s': %s" % (state_path, exc)
        observer.exception(msg)
        raise type(exc)(msg)

    return (state_name, state_path)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.util/src/openmdao/util/eggsaver.py/_write_state_file/original