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

(Partial) Fix https://github.com/giampaolo/psutil/issues/694 #1084

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions psutil/_pssunos.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,26 @@ def __init__(self, pid):

def oneshot_enter(self):
self._proc_name_and_args.cache_activate()
self._proc_environ.cache_activate()
self._proc_basic_info.cache_activate()
self._proc_cred.cache_activate()

def oneshot_exit(self):
self._proc_name_and_args.cache_deactivate()
self._proc_environ.cache_deactivate()
self._proc_basic_info.cache_deactivate()
self._proc_cred.cache_deactivate()

@memoize_when_activated
def _proc_name_and_args(self):
return cext.proc_name_and_args(self.pid, self._procfs_path)

@memoize_when_activated
def _proc_environ(self):
args = cext.proc_environ(self.pid, self._procfs_path)
if args:
return dict(args)

@memoize_when_activated
def _proc_basic_info(self):
ret = cext.proc_basic_info(self.pid, self._procfs_path)
Expand Down Expand Up @@ -414,6 +422,10 @@ def exe(self):
def cmdline(self):
return self._proc_name_and_args()[1].split(' ')

@wrap_exceptions
def environ(self):
return self._proc_environ()

@wrap_exceptions
def create_time(self):
return self._proc_basic_info()[proc_info_map['create_time']]
Expand Down
Loading