Skip to content

Commit

Permalink
update docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Sep 30, 2024
1 parent 5c2575e commit 06fb9c1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,23 @@ def _get_ident(self):
"""Return a (pid, uid) tuple which is supposed to identify a
Process instance univocally over time. The PID alone is not
enough, as it can be assigned to a new process after this one
terminates [1], so we add process creation time to the mix. We
need this in order to prevent killing the wrong process later
on.
terminates, so we add process creation time to the mix. We need
this in order to prevent killing the wrong process later on.
This is also known as PID reuse or PID recycling problem.
The reliability of this strategy mostly depends on
create_time() precision, which is 0.01 secs on Linux. The
assumption is that, after a process terminates, the kernel
won't reuse the same PID after such a short period of time
(0.01 secs). Technically this is inherently racy, but
practically it should be good enough.
[1] This is also known as PID reuse or PID recycling problem.
See: https://github.com/giampaolo/psutil/issues/2366#issuecomment-2381646555
"""
if WINDOWS:
# Use create_time() fast method in order to speedup
# `process_iter()`. This means we'll get AccessDenied for
# most ADMIN processes, but that's fine since it means
# we'll also get AccessDenied on kill().
# https://github.com/giampaolo/psutil/issues/2366#issuecomment-2381646555
self._create_time = self._proc.create_time(fast_only=True)
return (self.pid, self._create_time)
else:
Expand Down

0 comments on commit 06fb9c1

Please sign in to comment.