mirror of
https://github.com/python/cpython.git
synced 2026-06-04 16:50:51 +00:00
gh-150114: Fix get_process_memory_usage() on Windows (#150399)
Catch OSError if the process exited.
This commit is contained in:
parent
dfe7ef6292
commit
a189e3dd03
1 changed files with 5 additions and 2 deletions
|
|
@ -788,8 +788,11 @@ def _get_process_memory_usage_linux(pid: int) -> int | None:
|
|||
|
||||
def _get_process_memory_usage_windows(pid: int) -> int | None:
|
||||
assert _winapi is not None # to make mypy happy
|
||||
handle = _winapi.OpenProcess(_winapi.PROCESS_QUERY_LIMITED_INFORMATION,
|
||||
False, pid)
|
||||
try:
|
||||
handle = _winapi.OpenProcess(_winapi.PROCESS_QUERY_LIMITED_INFORMATION,
|
||||
False, pid)
|
||||
except OSError:
|
||||
return None
|
||||
try:
|
||||
mem_info = _winapi.GetProcessMemoryInfo(handle)
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue