diff --git a/gpiozero/input_devices.py b/gpiozero/input_devices.py index c3e5840..f1153f7 100644 --- a/gpiozero/input_devices.py +++ b/gpiozero/input_devices.py @@ -162,7 +162,7 @@ class SmoothedInputDevice(EventsMixin, InputDevice): except DeviceClosed: return super(SmoothedInputDevice, self).__repr__() else: - if self.partial or self._queue.full.wait(0): + if self.partial or self._queue.full.is_set(): return super(SmoothedInputDevice, self).__repr__() else: return "" % ( diff --git a/gpiozero/mixins.py b/gpiozero/mixins.py index fd110ae..62eed6c 100644 --- a/gpiozero/mixins.py +++ b/gpiozero/mixins.py @@ -234,7 +234,7 @@ class EventsMixin(object): The length of time (in seconds) that the device has been active for. When the device is inactive, this is ``None``. """ - if self._active_event.wait(0): + if self._active_event.is_set(): return time() - self._last_changed else: return None @@ -245,7 +245,7 @@ class EventsMixin(object): The length of time (in seconds) that the device has been inactive for. When the device is active, this is ``None``. """ - if self._inactive_event.wait(0): + if self._inactive_event.is_set(): return time() - self._last_changed else: return None @@ -434,11 +434,11 @@ class HoldThread(GPIOThread): self.start() def held(self, parent): - while not self.stopping.wait(0): + while not self.stopping.is_set(): if self.holding.wait(0.1): self.holding.clear() while not ( - self.stopping.wait(0) or + self.stopping.is_set() or parent._inactive_event.wait(parent.hold_time) ): if parent._held_from is None: diff --git a/tests/test_inputs.py b/tests/test_inputs.py index eec55e4..41a8e56 100644 --- a/tests/test_inputs.py +++ b/tests/test_inputs.py @@ -64,20 +64,20 @@ def test_input_event_activated(): pin = MockPin(2) with DigitalInputDevice(pin) as device: device.when_activated = lambda: event.set() - assert not event.wait(0) + assert not event.is_set() pin.drive_high() - assert event.wait(0) + assert event.is_set() def test_input_event_deactivated(): event = Event() pin = MockPin(2) with DigitalInputDevice(pin) as device: device.when_deactivated = lambda: event.set() - assert not event.wait(0) + assert not event.is_set() pin.drive_high() - assert not event.wait(0) + assert not event.is_set() pin.drive_low() - assert event.wait(0) + assert event.is_set() def test_input_wait_active(): pin = MockPin(2) diff --git a/tests/test_mock_pin.py b/tests/test_mock_pin.py index 92e1d3d..c8bdb95 100644 --- a/tests/test_mock_pin.py +++ b/tests/test_mock_pin.py @@ -160,15 +160,15 @@ def test_mock_pin_edges(): pin.when_changed = changed pin.drive_high() assert pin.state - assert fired.wait(0) + assert fired.is_set() fired.clear() pin.edges = 'falling' pin.drive_low() assert not pin.state - assert fired.wait(0) + assert fired.is_set() fired.clear() pin.drive_high() assert pin.state - assert not fired.wait(0) + assert not fired.is_set() assert pin.edges == 'falling'