OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # $Id: error.py 744 2010-10-27 22:42:42Z jloden $ | 3 # $Id: error.py 1142 2011-10-05 18:45:49Z g.rodola $ |
4 # | 4 # |
| 5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. |
| 6 # Use of this source code is governed by a BSD-style license that can be |
| 7 # found in the LICENSE file. |
5 | 8 |
6 """psutil exception classes""" | 9 """psutil exception classes; do not import this directly""" |
7 | 10 |
8 | 11 |
9 class Error(Exception): | 12 class Error(Exception): |
10 """Base exception class. All other psutil exceptions inherit | 13 """Base exception class. All other psutil exceptions inherit |
11 from this one. | 14 from this one. |
12 """ | 15 """ |
13 | 16 |
14 class NoSuchProcess(Error): | 17 class NoSuchProcess(Error): |
15 """Exception raised when a process with a certain PID doesn't | 18 """Exception raised when a process with a certain PID doesn't |
16 or no longer exists (zombie). | 19 or no longer exists (zombie). |
(...skipping 25 matching lines...) Expand all Loading... |
42 if (pid is not None) and (name is not None): | 45 if (pid is not None) and (name is not None): |
43 self.msg = "(pid=%s, name=%s)" % (pid, repr(name)) | 46 self.msg = "(pid=%s, name=%s)" % (pid, repr(name)) |
44 elif (pid is not None): | 47 elif (pid is not None): |
45 self.msg = "(pid=%s)" % self.pid | 48 self.msg = "(pid=%s)" % self.pid |
46 else: | 49 else: |
47 self.msg = "" | 50 self.msg = "" |
48 | 51 |
49 def __str__(self): | 52 def __str__(self): |
50 return self.msg | 53 return self.msg |
51 | 54 |
| 55 |
| 56 class TimeoutExpired(Error): |
| 57 """Raised on Process.wait(timeout) if timeout expires and process |
| 58 is still alive. |
| 59 """ |
| 60 |
| 61 def __init__(self, pid=None, name=None): |
| 62 self.pid = pid |
| 63 self.name = name |
| 64 if (pid is not None) and (name is not None): |
| 65 self.msg = "(pid=%s, name=%s)" % (pid, repr(name)) |
| 66 elif (pid is not None): |
| 67 self.msg = "(pid=%s)" % self.pid |
| 68 else: |
| 69 self.msg = "" |
| 70 |
| 71 def __str__(self): |
| 72 return self.msg |
| 73 |
OLD | NEW |