in benchmarking/platforms/device_manager.py [0:0]
def _handleDCDevices(self, online_hashes):
"""
If there are devices we expect to be connected to the host,
check if they are rebooting or have been put offline by the USBController,
else mark the device as unavailable and offline. After dc_threshold times
that the device is not seen, remove it completely and critically log.
"""
for h in online_hashes:
if h in self.device_dc_count:
device = [d for d in self.online_devices if d["hash"] == h][0]
getLogger().info(f"Device {device} has reconnected.")
self.device_dc_count.pop(h)
self._enableDevice(device)
dc_devices = [
device
for device in self.online_devices
if device["hash"] not in online_hashes
]
for dc_device in dc_devices:
kind = dc_device["kind"]
hash = dc_device["hash"]
lab_device = self.lab_devices[kind][hash]
usb_disabled = False
if self.usb_controller and not self.usb_controller.active.get(hash, True):
usb_disabled = True
if "rebooting" not in lab_device and not usb_disabled:
if hash not in self.device_dc_count:
getLogger().error(
f"Device {dc_device} is disconnected and has been marked unavailable for benchmarking.",
)
self._disableDevice(dc_device)
self.device_dc_count[hash] += 1
dc_count = self.device_dc_count[hash]
if dc_count < self.dc_threshold:
getLogger().error(
f"Device {dc_device} has shown as disconnected {dc_count} time(s) ({dc_count * self.device_monitor_interval}s)",
)
elif dc_count == self.dc_threshold:
getLogger().critical(
f"Device {dc_device} has shown as disconnected {dc_count} time(s) ({dc_count * self.device_monitor_interval}s) and is offline.",
)
self.online_devices.remove(dc_device)
self.device_dc_count.pop(hash)