Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-112278: reduce time cost for platform module when no permission to WMI on Windows#112658

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
zooba merged 6 commits intopython:mainfromaisk:platform-wmi-timeout
Dec 7, 2023

Conversation

aisk
Copy link
Contributor

@aiskaisk commentedDec 3, 2023
edited
Loading

Using anEvent object to simulate timeout forIWbemLocator::ConnectServer. I set it to 100ms, and it's enough for the normal path on my machine. And there have another 100ms plus for waiting the query thread. The final time usage on my local machine:

PS C:\Users\xxxxx\Source\cpython> .\python.bat -m timeit -s "import platform" -n 1 -r 1 "platform.system()"Running Debug|x64 interpreter...1 loop, best of 1: 301 msec per loop

Comment on lines 332 to 335
global _wmi_query
def _wmi_query(table, *keys):
raise OSError("not supported")
raise OSError("not supported")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let's restructure this import block to make_wmi = None when it fails to import, and then if we fail to query it can clear out_wmi and subsequent calls will act as if it were never imported.

@aisk
Copy link
ContributorAuthor

aisk commentedDec 5, 2023

Updated, ready for review.

@aiskaisk requested a review fromzoobaDecember 6, 2023 15:10
@zoobazooba merged commita955fd6 intopython:mainDec 7, 2023
@zooba
Copy link
Member

Will add the backport to 3.12 after 3.12.1 has settled.

aisk reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobaAwaiting requested review from zooba

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@aisk@zooba

[8]ページ先頭

©2009-2025 Movatter.jp