diff --git a/tuned/consts.py b/tuned/consts.py index 48c80f0dd..38c85220a 100644 --- a/tuned/consts.py +++ b/tuned/consts.py @@ -215,3 +215,8 @@ "console": LOG_LEVEL_CONSOLE, "none": None, } + +# number of retries when waiting for device initialization +HOTPLUG_WAIT_FOR_DEV_INIT_RETRIES = 100 +# how long to wait for device initialization in seconds during retry +HOTPLUG_WAIT_FOR_DEV_INIT_DELAY = 0.1 diff --git a/tuned/hardware/inventory.py b/tuned/hardware/inventory.py index a08e45609..93c95701c 100644 --- a/tuned/hardware/inventory.py +++ b/tuned/hardware/inventory.py @@ -54,6 +54,14 @@ def _handle_udev_event(self, event, device): if not device.subsystem in self._subscriptions: return + retry = consts.HOTPLUG_WAIT_FOR_DEV_INIT_RETRIES + while not device.is_initialized and retry > 0: + log.debug("Device '%s' is uninitialized, waiting '%.2f' seconds for its initialization." % (device, consts.HOTPLUG_WAIT_FOR_DEV_INIT_DELAY)) + time.sleep(consts.HOTPLUG_WAIT_FOR_DEV_INIT_DELAY) + retry =- 1 + if not device.is_initialized: + log.warn("Unsuccessfully waited for device '%s' initialization, continuing with uninitialized device, problems may occur." % device) + for (plugin, callback) in self._subscriptions[device.subsystem]: try: callback(event, device)