Skip to content

Add pid and msg attributes to NoSuchProcess and AccessDenied exceptions #95

Closed
@giampaolo

Description

From g.rodola on June 11, 2010 22:03:34

This would be useful, for example, when iterating over different 
Process instances to know the ID of the process which raised the exception and the exact reason.

Example:

import psutil

for pid in psutil.get_pid_list():
    try:
        p = psutil.Process(pid)
        p.create_time
    except (psutil.NoSuchProcess, psutil.AccessDenied), err:
        print "exception for pid:%s, reason:%s", % (err.pid, err.msg)
        raise err

Ideally, pid argument should always be mandatory for the function which raises the exception while msg can be left optional.

Both psutil.NoSuchProcess and psutil.AccessDenied should inherit from a generic psutil.Error exception that can be used to catch both.

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

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions