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

Docs: pid_exists() Please give an advice #1450

Closed
guettli opened this issue Mar 8, 2019 · 1 comment
Closed

Docs: pid_exists() Please give an advice #1450

guettli opened this issue Mar 8, 2019 · 1 comment
Assignees

Comments

@guettli
Copy link
Contributor

guettli commented Mar 8, 2019

Docs of pid_exists() could get improved:

https://psutil.readthedocs.io/en/latest/#psutil.pid_exists

New comers might think that a True value returned from pid_exists() is a reliable value.

But of course it is not.

Few milliseconds later the process could already have terminated.

You can only trust the result "this process has terminated". The result "this process is still alive" only matches the past, not the current situation.

I am not a native speaker. That's why I hesitate to create a pull request. I think your wording would be easier to understand.

@giampaolo
Copy link
Owner

giampaolo commented Mar 11, 2019

Both pid_exists() and instantiating Processes by by iterating over pids() is inherently racy. The doc already mentions that discouraging the use of pids() in favor of process_iter(). It doesn't mention the racy nature of pid_exists() specifically because I think it should be clear already.

PS - I'm also a non-native speaker btw (I'm Italian). =)

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