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

[OS] process_iter() cached item ignored the killed process #1951

Closed
rsik88 opened this issue May 17, 2021 · 1 comment
Closed

[OS] process_iter() cached item ignored the killed process #1951

rsik88 opened this issue May 17, 2021 · 1 comment

Comments

@rsik88
Copy link

rsik88 commented May 17, 2021

Summary

  • OS: { Centos 8 }
  • Architecture: { 64bit, 3 }
  • Psutil version: { 5.8.0 }
  • Python version: { 3.6.8 }
  • Type: { core }

Description

{{{
psutil.process_iter() call caches pid etc. When a process restarted, it didn't update and still keeps the old pid. It would be nice to have a function to allow refresh the process list when needed.
}}}

@rsik88 rsik88 added the bug label May 17, 2021
@github-actions github-actions bot added the linux label May 17, 2021
@giampaolo
Copy link
Owner

process_iter() is already supposed to handle PIDs being reused, see:

psutil/psutil/__init__.py

Lines 1444 to 1453 in 5d39cc9

# use is_running() to check whether PID has been
# reused by another process in which case yield a
# new Process instance
if proc.is_running():
if attrs is not None:
proc.info = proc.as_dict(
attrs=attrs, ad_value=ad_value)
yield proc
else:
yield add(pid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants