def advance_until(self, final_state):
        """Instructs the CopyingManager thread to keep advancing through its blocking states until it reaches the
        named one.

        @param final_state:  The name of the state to wait for (such as "sleeping", "blocked_on_receive", etc.
        @type final_state: str
        """
        self.__test_state_cv.acquire()
        original_count = self.__test_state_changes

        # We have to keep incrementing the __advanced_requests count so that the copying manager thread keeps
        # advancing.  We wait on the test_state_cv because everytime the CopyingManager blocks, it notifies that cv.
        while self.__test_state_changes <= original_count or self.__test_state != final_state:
            self.__advance_requests_cv.acquire()
            self.__advance_requests += 1
            self.__advance_requests_cv.notifyAll()
            self.__advance_requests_cv.release()
            self.__test_state_cv.wait()

        self.__test_state_cv.release()
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/tests/copying_manager_test.py/TestableCopyingManager.advance_until/original