Comments (6)
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.
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.
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.
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.
From [email protected] on February 23, 2009 09:49:02
Labels: -Component-Library
from psutil.
From g.rodola on March 02, 2013 03:39:40
Updated csets after the SVN -> Mercurial migration: r124 == revision
from psutil.
Related Issues (20)
- [CentOS 5] ethtool.h : error: unknown type name '__u32' HOT 1
- [CentOS Stream 10] test_linux.TestSystemCPUFrequency.test_emulate_multi_cpu fails on aarch64 HOT 3
- [CentOS Stream 10] test_misc.TestCommonModule.test_debug often fails on ppc64le, s390x, or aarch64 HOT 5
- [Enhancement] Refactoring of test HOT 1
- [Linux] psutil.tests.test_posix.TestProcess.test_nice fails under non-realtime scheduling policy HOT 2
- [OS] title Windows
- [macOS] cpu_freq() fails on arm64 HOT 6
- [Windows] as_dict() failing for win_service_get('WaaSMedicSvc')
- [Windows]Why are the indicators collected by psuntil too large? HOT 5
- [Linux] Distribute linux wheels for python versions > 3.6 on x86 and arm64 HOT 1
- [Linux] run "python3 -m psutil.tests", some test cases failed when nfs boot is used
- [Windows 10] psutil.process_iter() seems to be stuck
- [Linux] psutil.tests.test_linux.TestSystemVirtualMemoryAgainst tests failing
- [Linux] Get laptop charging speed (in Watts)
- process_iter(): no longer check whether PIDs have been reused
- [Linux / FreeBSD] evaluate using `pidfd_send_signal()` for signaling processes HOT 5
- Don't build with limited API for 3.13 free-threaded build
- [macOS] active system memory is inaccurate HOT 1
- Rename Process.connections() to Process.net_connections()
- Remove deprecated `Process.memory_info_ex()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psutil.