@contextlib.contextmanager
def pause(self):
    with self._condition:
        self._paused = True
    (yield)
    with self._condition:
        self._paused = False
        self._condition.notify_all()
@contextlib.contextmanager
def pause(self):
    with self._condition:
        self._paused = True
    (yield)
    with self._condition:
        self._paused = False
        self._condition.notify_all()