'Context manager that controls access to event dispatcher for
preventing reentrancy.
The "as" value is True if the managed code block owns the event
dispatcher and False if caller higher up in the call stack already owns
it. Only managed code that gets ownership (got True) is permitted to
dispatch'

@contextlib.contextmanager
def _acquire_event_dispatch(self):

    try:
        self._event_dispatch_suspend_depth += 1
        (yield (self._event_dispatch_suspend_depth == 1))
    finally:
        self._event_dispatch_suspend_depth -= 1
