def METHOD_NAME(*args, **kwargs):
    try:
        ret = f(*args, **kwargs)
        if isinstance(ret, libvirt.virDomain):
            for name in dir(ret):
                method = getattr(ret, name)
                if callable(method) and name[0] != '_':
                    setattr(ret, name,
                            wrapMethod(function.weakmethod(method)))
        return ret
    except libvirt.libvirtError as e:
        edom = e.get_error_domain()
        ecode = e.get_error_code()
        EDOMAINS = (libvirt.VIR_FROM_REMOTE,
                    libvirt.VIR_FROM_RPC)
        ECODES = (libvirt.VIR_ERR_SYSTEM_ERROR,
                  libvirt.VIR_ERR_INTERNAL_ERROR,
                  libvirt.VIR_ERR_NO_CONNECT,
                  libvirt.VIR_ERR_INVALID_CONN)
        if edom in EDOMAINS and ecode in ECODES:
            try:
                __connections.get(id(target)).pingLibvirt()
            except libvirt.libvirtError as e:
                edom = e.get_error_domain()
                ecode = e.get_error_code()
                if edom in EDOMAINS and ecode in ECODES:
                    log.warning('connection to libvirt broken.'
                                ' ecode: %d edom: %d', ecode, edom)
                    if killOnFailure:
                        log.critical('taking calling process down.')
                        os.kill(os.getpid(), signal.SIGTERM)
                    else:
                        raise
        raise