more tweaks to idle polling
This commit is contained in:
parent
17863c85b6
commit
5cf6777340
|
@ -397,7 +397,7 @@ def request(handle, devnumber, request_id, *params):
|
|||
# _log.debug("(%s) still waiting for reply, delta %f", handle, delta)
|
||||
|
||||
if delta >= timeout:
|
||||
_log.warn("timeout on device %d request {%04X} params[%s]", devnumber, request_id, _strhex(params))
|
||||
_log.warn("timeout on device %d request {%04X} params [%s]", devnumber, request_id, _strhex(params))
|
||||
break
|
||||
# raise DeviceUnreachable(number=devnumber, request=request_id)
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ _EVENT_READ_TIMEOUT = 0.5
|
|||
|
||||
# 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
|
||||
_IDLE_READS = (5 / 0.5) # wait at least 5 seconds between ticks
|
||||
|
||||
|
||||
class EventsListener(_threading.Thread):
|
||||
|
@ -140,7 +140,7 @@ class EventsListener(_threading.Thread):
|
|||
last_tick = 0
|
||||
# the first idle read -- delay it a bit, and make sure to stagger
|
||||
# idle reads for multiple receivers
|
||||
idle_reads = _IDLE_READS * 2 + (ihandle % 3) * 3
|
||||
idle_reads = _IDLE_READS * 2 + (ihandle % 3) * 4
|
||||
|
||||
while self._active:
|
||||
if self._queued_notifications.empty():
|
||||
|
|
|
@ -176,8 +176,8 @@ class PairedDevice(object):
|
|||
|
||||
if enable:
|
||||
set_flag_bits = ( _hidpp10.NOTIFICATION_FLAG.battery_status
|
||||
+ _hidpp10.NOTIFICATION_FLAG.wireless
|
||||
+ _hidpp10.NOTIFICATION_FLAG.software_present )
|
||||
| _hidpp10.NOTIFICATION_FLAG.wireless
|
||||
| _hidpp10.NOTIFICATION_FLAG.software_present )
|
||||
else:
|
||||
set_flag_bits = 0
|
||||
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||
|
@ -282,8 +282,8 @@ class Receiver(object):
|
|||
|
||||
if enable:
|
||||
set_flag_bits = ( _hidpp10.NOTIFICATION_FLAG.battery_status
|
||||
+ _hidpp10.NOTIFICATION_FLAG.wireless
|
||||
+ _hidpp10.NOTIFICATION_FLAG.software_present )
|
||||
| _hidpp10.NOTIFICATION_FLAG.wireless
|
||||
| _hidpp10.NOTIFICATION_FLAG.software_present )
|
||||
else:
|
||||
set_flag_bits = 0
|
||||
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||
|
|
|
@ -38,7 +38,7 @@ def _ghost(device):
|
|||
|
||||
# how often to poll devices that haven't updated their statuses on their own
|
||||
# (through notifications)
|
||||
_POLL_TICK = 4 * 60 # seconds
|
||||
_POLL_TICK = 5 * 60 # seconds
|
||||
|
||||
|
||||
class ReceiverListener(_listener.EventsListener):
|
||||
|
@ -193,7 +193,8 @@ class ReceiverListener(_listener.EventsListener):
|
|||
#
|
||||
#
|
||||
|
||||
# all currently running receiver listeners
|
||||
# all known receiver listeners
|
||||
# listeners that stop on their own may remain here
|
||||
_all_listeners = {}
|
||||
|
||||
|
||||
|
@ -214,9 +215,11 @@ def stop_all():
|
|||
_all_listeners.clear()
|
||||
|
||||
for l in listeners:
|
||||
l.stop()
|
||||
if l:
|
||||
l.stop()
|
||||
for l in listeners:
|
||||
l.join()
|
||||
if l:
|
||||
l.join()
|
||||
|
||||
|
||||
_status_callback = None
|
||||
|
|
Loading…
Reference in New Issue