From cec892ce8874c9792005b35492ac2c841c8e01cc Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Sun, 23 Jun 2013 18:15:19 +0200 Subject: [PATCH] disable poll ticking It was necessary to periodically check if the peripherals are still online -- suspend/resume may cause Solaar to (wrongfully) remember the status of devices after a resume. Now that is handled by the optional upower module -- the hard way -- by restarting all listeners on resume. --- lib/logitech/unifying_receiver/listener.py | 6 ++++-- lib/solaar/listener.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/logitech/unifying_receiver/listener.py b/lib/logitech/unifying_receiver/listener.py index 7f373c58..5ccc489f 100644 --- a/lib/logitech/unifying_receiver/listener.py +++ b/lib/logitech/unifying_receiver/listener.py @@ -102,11 +102,13 @@ class _ThreadedHandle(object): # Ideally this should be rather long (10s ?), but the read is blocking # and this means that when the thread is signalled to stop, it would take # a while for it to acknowledge it. -_EVENT_READ_TIMEOUT = 0.5 +# Forcibly closing the file handle on another thread does _not_ interrupt the +# read on Linux systems. +_EVENT_READ_TIMEOUT = 0.4 # in seconds # After this many reads that did not produce a packet, call the tick() method. # This only happens if tick_period is enabled (>0) for the Listener instance. -_IDLE_READS = (5 / 0.5) # wait at least 5 seconds between ticks +_IDLE_READS = 1 + int(5 // _EVENT_READ_TIMEOUT) # wait at least 5 seconds between ticks class EventsListener(_threading.Thread): diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index 7a4c4b8f..28b20aab 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -47,7 +47,7 @@ class ReceiverListener(_listener.EventsListener): def __init__(self, receiver, status_changed_callback): super(ReceiverListener, self).__init__(receiver, self._notifications_handler) # no reason to enable polling yet - self.tick_period = _POLL_TICK + # self.tick_period = _POLL_TICK self._last_tick = 0 assert status_changed_callback