'Returns closure that when called calls f and then callbacks d.'

def _fireWhenDoneFunc(self, d, f):

    @wraps(f)
    def newf(*args, **kw):
        rtn = f(*args, **kw)
        d.callback('')
        return rtn
    return newf
