def METHOD_NAME(self, wait=False):
    """
    Cancel all scheduled calls and stop the scheduler. Scheduling calls
    after the scheduler was stopped will raise AssertionError.
    """
    self._log.debug("Stopping scheduler %s", self._name)
    with self._cond:
        self._running = False
        self._cond.notify()
    if wait:
        self._thread.join()