fix: Set timeout for device info loading to prevent infinite waiting#531
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom Sep 5, 2025
Merged
Conversation
- Change waitForDone(-1) to waitForDone(60000) in MainJob::updateAllDevice() - Add 60-second timeout to prevent device manager from hanging during device info loading - Improve application responsiveness and user experience Log: Set timeout for device info loading to prevent infinite waiting Bug: https://pms.uniontech.com/bug-view-331983.html Change-Id: Iab0310719df4cfa7e13176975ee0db59572d88ce
deepin pr auto review这段代码的修改是将
改进建议:
修改后的代码如下(建议): void MainJob::updateAllDevice()
{
PERF_PRINT_START("POINT-01");
const int DEVICE_INFO_UPDATE_TIMEOUT = 60000; // 定义超时常量
if (m_firstUpdate)
m_pool->loadDeviceInfo();
else
m_pool->updateDeviceInfo();
bool success = m_pool->waitForDone(DEVICE_INFO_UPDATE_TIMEOUT);
if (!success) {
// 添加超时处理逻辑
qWarning() << "Device info update timed out after" << DEVICE_INFO_UPDATE_TIMEOUT << "ms";
}
PERF_PRINT_END("POINT-01");
m_firstUpdate = false;
}这样的修改不仅提高了代码的可读性和可维护性,还增加了错误处理机制,使代码更加健壮。 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplace the indefinite wait on device info loading with a 60-second timeout in MainJob::updateAllDevice to avoid hangs and improve responsiveness. Sequence diagram for device info loading with timeoutsequenceDiagram
participant MainJob
participant DevicePool
MainJob->>DevicePool: loadDeviceInfo() or updateDeviceInfo()
MainJob->>DevicePool: waitForDone(60000)
DevicePool-->>MainJob: Done or Timeout after 60s
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Consider extracting the 60000ms timeout into a named constant or configuration setting instead of using a hardcoded magic number.
- Add explicit handling or logging for when waitForDone times out so that failures in device info loading are surfaced.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the 60000ms timeout into a named constant or configuration setting instead of using a hardcoded magic number.
- Add explicit handling or logging for when waitForDone times out so that failures in device info loading are surfaced.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
GongHeng2017
approved these changes
Sep 5, 2025
max-lvs
approved these changes
Sep 5, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, GongHeng2017, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log: Set timeout for device info loading to prevent infinite waiting
Bug: https://pms.uniontech.com/bug-view-331983.html
Change-Id: Iab0310719df4cfa7e13176975ee0db59572d88ce
Summary by Sourcery
Add a 60-second timeout to m_pool->waitForDone in MainJob::updateAllDevice to prevent the device manager from hanging indefinitely when loading device info.
Bug Fixes:
Enhancements: