polling: it may happen that the receiver is removed mid-poll
This commit is contained in:
parent
cd44cc6396
commit
56a7a960c3
|
|
@ -81,10 +81,6 @@ class ReceiverListener(_listener.EventsListener):
|
||||||
if not self.tick_period:
|
if not self.tick_period:
|
||||||
raise Exception("tick() should not be called without a tick_period: %s", self)
|
raise Exception("tick() should not be called without a tick_period: %s", self)
|
||||||
|
|
||||||
if not self.receiver:
|
|
||||||
# just in case the receiver was just removed
|
|
||||||
return
|
|
||||||
|
|
||||||
# not necessary anymore, we're now using udev monitor to watch for receiver status
|
# not necessary anymore, we're now using udev monitor to watch for receiver status
|
||||||
# if self._last_tick > 0 and timestamp - self._last_tick > _POLL_TICK * 2:
|
# if self._last_tick > 0 and timestamp - self._last_tick > _POLL_TICK * 2:
|
||||||
# # if we missed a couple of polls, most likely the computer went into
|
# # if we missed a couple of polls, most likely the computer went into
|
||||||
|
|
@ -95,6 +91,7 @@ class ReceiverListener(_listener.EventsListener):
|
||||||
|
|
||||||
self._last_tick = timestamp
|
self._last_tick = timestamp
|
||||||
|
|
||||||
|
try:
|
||||||
# read these in case they haven't been read already
|
# read these in case they haven't been read already
|
||||||
# self.receiver.serial, self.receiver.firmware
|
# self.receiver.serial, self.receiver.firmware
|
||||||
if self.receiver.status.lock_open:
|
if self.receiver.status.lock_open:
|
||||||
|
|
@ -115,6 +112,8 @@ class ReceiverListener(_listener.EventsListener):
|
||||||
assert dev
|
assert dev
|
||||||
if dev.status is not None:
|
if dev.status is not None:
|
||||||
dev.status.poll(timestamp)
|
dev.status.poll(timestamp)
|
||||||
|
except Exception as e:
|
||||||
|
_log.exception("polling", e)
|
||||||
|
|
||||||
def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None):
|
def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None):
|
||||||
assert device is not None
|
assert device is not None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue