Giter Club home page Giter Club logo

Comments (6)

giampaolo avatar giampaolo commented on May 22, 2024

From [email protected] on February 17, 2009 09:14:30

I think this exception only occurs on Linux - other platforms would end up 
None values for everything except PID when calling 
Regardless, probably not desired behavior, I think a NoSuchProcess exception or
something similar makes more sense.

We can check if the PID exists by just doing a "if pid not in
_platform_impl.get_pid_list()" in the constructor. Maybe it makes sense to 
pid_exists(pid) method for reuse also. It'd be nice if we didn't have to incur 
overhead every time we create a Process object, but I don't see another way to 

We should probably also consider what to do in the event the PID disappears 
create the Process object. For example: 

    myProc = Process(1234)
    time.sleep(5)         # time-consuming task, process dies in meantime
    print myProc.name 

Because the name property will *then* trigger a deproxy() and calling
get_process_info() we'll basically end up with a bunch of None values for name, 
cmdline, etc. Maybe get_process_info() should also raise an exception if the 
longer exists/is defunct for whatever reason. If they've already deproxied and 
get_process_info() successfully then I would say leave the values alone.

Finally, I can see a case for a is_running() method to the Process object. That 
users can check on a process if needed. After the Process object has been 
if the process dies out there's currently no way to tell unless you were to 
check for the PID in the process list.

from psutil.

giampaolo avatar giampaolo commented on May 22, 2024

From [email protected] on February 17, 2009 21:54:00

Since our Linux implementation relies uniquely on reading files in /proc a 
*could* be "wrapping" every _pslinux.Impl() method into an implicit try/except 
by using a decorator and check for IOError "No such file" exceptions.
When such an event occurs we assume it's because the process has died in the 
and raise NoSuchProcess instead.

The patch in attachment does that.
I called the decorator "prevent_zombie" since I didn't find anything better. =)

If this is what we want, using a decorator could be both practical and elegant 
I don't know if replicating this same behavior on other platforms relying on C
extension would be possible.
Could someone clarify me this point?

Attachment: psutil.patch

from psutil.

giampaolo avatar giampaolo commented on May 22, 2024

From [email protected] on February 18, 2009 09:16:50

Implemented NoSuchProcess exception in r124 As far as using a decorator, it 
However, I think it's a bad idea to have a case where a NoSuchObject exception 
raised *after* the Process object is created, especially in the middle of a 
call or while accessing one of the properties. 

That being said, our Process object doesn't necessarily have
_platform_impl.get_process_info() called right away, so we need to figure out 
handle it if someone creates the Process object and doesn't trigger deproxy() 
away. In the meantime if the process goes away, then when they finally do 
deproxy() it would fail to fetch the process information. I'm loathe to just 
trigger a NoSuchObject exception all of the sudden when the user tries to 
of the properties, but I don't at the moment have an alternative suggestion. 
need to think about this and discuss internally before we implement something, 
make it consistent across platforms. Perhaps it would be best to move this 
to a separate issue # and close out this one since the exception has been 
non-existent PID in the constructor.

Status: Accepted

from psutil.

giampaolo avatar giampaolo commented on May 22, 2024

From [email protected] on February 18, 2009 10:29:42

We can discuss about what to do if the process dies before we fill out the 
info in Issue 15 .
I'm closing out this one as "Fixed".

Status: Fixed
Owner: jloden
Labels: Milestone-0.1.1 Component-Library

from psutil.

giampaolo avatar giampaolo commented on May 22, 2024

From [email protected] on February 23, 2009 09:49:02

Labels: -Component-Library

from psutil.

giampaolo avatar giampaolo commented on May 22, 2024

From g.rodola on March 02, 2013 03:39:40

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

from psutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.