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

An exception should be raised when retrieving info about a dead process #15

Closed
giampaolo opened this issue May 23, 2014 · 8 comments
Closed
Assignees

Comments

@giampaolo
Copy link
Owner

From billiej...@gmail.com on February 18, 2009 19:25:40

What steps will reproduce the problem?  
1. p = Process(1234)
2. time.sleep(5)  # time-consuming task, process dies in meantime
3. p.name 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "psutil/psutil.py", line 69, in name
    self.deproxy()
  File "psutil/psutil.py", line 58, in deproxy
    self._procinfo = _platform_impl.get_process_info(self._procinfo.pid)
  File "psutil/_pslinux.py", line 39, in get_process_info
    f = open("/proc/&#37;s/stat" &#37;pid)
IOError: [Errno 2] No such file or directory: '/proc/1234/stat'


As discussed in Issue 12 it would make sense that NoSuchProcess is raised
when we attempt to retrieve info from a Process() instance referring to a
process which is dead in meantime. Issue 12 includes a patch which solves this 
anything we should figure out how to implement that same thing on Windows
and OS X in a reliable way as well.

As pointed out by Jay it seems acceptable that we check for process
"aliveness" only when calling get_process_info() and avoid to raise
NoSuchProcess in case the process dies later.

Original issue: http://code.google.com/p/psutil/issues/detail?id=15

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on February 20, 2009 04:42:05

Fixed on Linux as r135 .

Status: Started
Labels: Milestone-0.1.1

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on February 20, 2009 08:33:41

This is as fixed as it's going to get for now on OS X and Windows... We're just
checking if the PID exists right before executing the code to retrieve process
information. Ideally we would have some more definitive way to determine if the
process dies in mid-data collection but realistically dealing with process 
always going to be a race condition where the process can randomly disappear at 
moment. 

For now we raise an exception in the majority of cases, but theoretically it is
probably possible that we might end up returning invalid values (e.g. None), 
the process go away while get_process_info() is still executing.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on February 20, 2009 14:12:27

Owner: jloden

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on February 20, 2009 18:04:27

get_process_info() should raise an exception if any part of data collection 
both Windows and OS X. If Linux platform is completed we can close this out.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on February 23, 2009 09:49:02

Labels: -Component-Library

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on February 23, 2009 19:27:17

The test case for this issue has been added a while ago and it's reasonably 
so if you haven't reported any failure for OS X I guess everything should be 
Closing this out as Verified.

Status: Verified

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 17, 2009 08:31:20

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:42:20

Updated csets after the SVN -> Mercurial migration: r135 == revision 

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

1 participant