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

handle exception forpsutil.NoSuchProcess along withpsutil.AccessDenied#401

Open
yeggor wants to merge 1 commit intopythonprofilers:masterfrom
yeggor:bugfix/no-such-process
Open

handle exception forpsutil.NoSuchProcess along withpsutil.AccessDenied#401
yeggor wants to merge 1 commit intopythonprofilers:masterfrom
yeggor:bugfix/no-such-process

Conversation

@yeggor
Copy link

Hi. I've noticed that there can be a condition where process will be killed between

process=psutil.Process(pid)
and
mem=getattr(process,meminfo_attr)()[0]/_TWO_20

In this case, we get an exceptionpsutil.NoSuchProcess: process no longer exists (pid=...), that we have to handle the same way as it's done here:

except (psutil.NoSuchProcess,psutil.AccessDenied):

@yeggor
Copy link
Author

here is trace frommprof run in case of triggered issue:

  File "/Users/user/pyenv/lib/python3.11/site-packages/mprof.py", line 283, in run_action    mp.memory_usage(proc=p, interval=args.interval, timeout=args.timeout, timestamps=True,  File "/Users/user/pyenv/lib/python3.11/site-packages/memory_profiler.py", line 405, in memory_usage    mem_usage = _get_memory(                ^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/memory_profiler.py", line 221, in _get_memory    return tools[backend]()           ^^^^^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/memory_profiler.py", line 140, in ps_util_tool    mem = getattr(process, meminfo_attr)()[0] / _TWO_20          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/_common.py", line 486, in wrapper    raise raise_from(err, None)          ^^^^^^^^^^^^^^^^^^^^^  File "<string>", line 3, in raise_from  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/_common.py", line 484, in wrapper    return fun(self)           ^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/__init__.py", line 1084, in memory_info    return self._proc.memory_info()           ^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/_psosx.py", line 346, in wrapper    return fun(self, *args, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/_psosx.py", line 444, in memory_info    rawtuple = self._get_pidtaskinfo()               ^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/user/pyenv/lib/python3.11/site-packages/psutil/_psosx.py", line 351, in wrapper    raise NoSuchProcess(self.pid, self._name)psutil.NoSuchProcess: process no longer exists (pid=80279)

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@yeggor

[8]ページ先頭

©2009-2026 Movatter.jp