def __init__(self, base_path, parent=None): super().__init__(parent) self.current: Optional[str] = None self._base_path = base_path self._last_window_session = None self.did_load = False # throttle autosaves to one minute apart self.save_autosave = throttle.Throttle(self._save_autosave, 60 * 1000)
def test_deleted_object(qtbot): class Obj(QObject): def func(self): self.setObjectName("test") obj = Obj() throttled = throttle.Throttle(obj.func, 100, parent=obj) throttled() throttled() sip.delete(obj) qtbot.wait(150)
def test_set(func, qtbot): throttled = throttle.Throttle(func, 100) throttled.set_delay(100) throttled("foo") throttled("foo") throttled("foo") throttled("bar") func.assert_called_once_with("foo") func.reset_mock() qtbot.wait(150) func.assert_called_once_with("bar") func.reset_mock()
def test_set(func, qtbot): throttled = throttle.Throttle(func, DELAY) throttled.set_delay(DELAY) throttled("foo") throttled("foo") throttled("foo") throttled("bar") func.assert_called_once_with("foo") func.reset_mock() qtbot.wait(int(1.5 * DELAY)) func.assert_called_once_with("bar") func.reset_mock()
def __init__(self, parent=None): """Constructor. Set percentage to 0%.""" super().__init__(parent, elidemode=Qt.ElideNone) self._strings = self._calc_strings() self._set_text = throttle.Throttle(self.setText, 100, parent=self) self.set_perc(0, 0)
def throttled(func): return throttle.Throttle(func, 100)
def throttled(func): return throttle.Throttle(func, DELAY)