Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotplug: wait for device initialization #637

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tuned/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions tuned/hardware/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading