def METHOD_NAME(self, onResult, func, *args, **kw):
    self.calls += 1
    try:
        result = func(*args, **kw)
    except:  # noqa pylint: disable=bare-except
        # We catch *everything* here, since normally this code would be
        # running in a thread, where there is nothing that will catch
        # error.
        onResult(False, Failure())
    else:
        onResult(True, result)