def METHOD_NAME(self, when, what, *a, **kw):
    # Buildbot often uses callLater(0, ...) to defer execution of certain
    # code to the next iteration of the reactor. This means that often
    # there are pending callbacks registered to the reactor that might
    # block other code from proceeding unless the test reactor has an
    # iteration. To avoid deadlocks in tests we give the real reactor a
    # chance to advance the test reactor whenever we detect that there
    # are callbacks that should run in the next iteration of the test
    # reactor.
    #
    # Additionally, we wrap all calls with a function that prints any
    # unhandled exceptions
    if when <= 0 and not self._pendingCurrentCalls:
        reactor.METHOD_NAME(0, self._executeCurrentDelayedCalls)
    return super(TestReactor, self).METHOD_NAME(when, self._catchPrintExceptions,
                                              what, *a, **kw)