Comments (9)
From [email protected] on March 09, 2009 18:07:07
I looked into the C code by using some debugging prints and it seems that the culprit
is OpenProcess() which doesn't return NULL, maybe because it automatically caches
handlers of processes which existed in system process table.
By running the code below the exception is thrown at the last instruction.
Since it seems we can't rely on OpenProcess() we might borrow some of the code we
used in get_process_info() to make it raise NSP when necessary.
import time, subprocess
from psutil import Process
sub = subprocess.Popen('python')
time.sleep(0.1)
p = Process(sub.pid)
p.kill()
time.sleep(0.5)
p.create_time
p.create_time
p = Process(sub.pid)
from psutil.
From [email protected] on March 12, 2009 09:47:44
It's the same problem we had before, OpenProcess() will succeed even if the process
no longer exists in many cases, you have to also check the exit code of the process.
There's already a BOOL is_running(HANDLE hProcess) function in
arch/mswindows/process_info.c that returns TRUE or FALSE if the process is actually
running.
However, even if you call is_running() right before getting process times, it won't
necessarily help if the process dies after that but before GetProcessTimes(). We need
to know what error code is being returned if GetProcessTimes() fails because the
process has gone away (e.g. ERROR_ACCESS_DENIED, ERROR_INVALID_PARAMETER). The only
way to find out is reproduce the error without suppressing the exception the way the
test case does and get the error code from the exception raised, or use printf
debugging to print GetLastError(). We already check for ERROR_ACCESS_DENIED from
GetProcessTimes() so maybe it's returning INVALID_PARAMETER to indicate a process
handle to a dead process?
Status: Accepted
from psutil.
From [email protected] on March 12, 2009 10:01:24
Actually, this one is different. If you print the value, you'll see that
get_create_time() is actually returning a real value, there's no error. There's no
NoSuchProcess exception raised, because the function actually succeeds in getting the
process create time. I haven't checked, but since both functions are calling
GetProcessTimes() it's likely the same thing is happening in get_cpu_times() too.
I suggest we just close this as WontFix, and remove the assertions from the test
suite. If these functions succeed on a process that has recently died, then there's
no reason IMO to force our properties to raise an exception. If the function call to
GetProcessTimes() fails, then I think it makes sense for us to raise an exception,
which are already doing.
from psutil.
From [email protected] on March 12, 2009 11:46:53
Removed tests as r246 .
Status: WontFix
from psutil.
From [email protected] on February 22, 2010 15:22:32
(related to issue 76 )
It seems that GetExitProcess() ( r512 ) can solve this problem.
Comments?
Status: ReOpened
Labels: -Milestone-0.1.2
from psutil.
From [email protected] on February 22, 2010 15:40:25
Status: WaitingForReview
from psutil.
From [email protected] on February 28, 2010 17:01:03
Is this fixed? I don't see any errors from test_zombie_process on my Windows machine
from psutil.
From [email protected] on March 01, 2010 00:19:19
Yes, it's fixed. We are now using GetExitProcess() every time we use OpenProcess(),
which seems the right thing to do.
Status: Fixed
from psutil.
From g.rodola on March 02, 2013 03:47:08
Updated csets after the SVN -> Mercurial migration: r246 == revision 1cd2a04e4049 r512 == revision 27636ff3db58
from psutil.
Related Issues (20)
- Questions about Copilot + Open Source Software Hierarchy
- [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 HOT 1
- [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()`
- [macOS] psutil.Process(pid).cpu_percent calculation result is inaccurate HOT 6
- [macOS] Lacking defines in <sys/mount.h> breaks build on legacy OS X HOT 1
- [Windows] Python 3.10 wheels are missing on PYPI for psutil 5.9.8
- blkio_ticks is not supported in solaris based system. (ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks')
- [Debian 12 bookworm] Repeating spikes in temperatures samples HOT 3
- About Error `FileNotFoundError: [Errno 2] No such file or directory: '/proc/12825/stat'` the some suggest HOT 1
- [Linux] cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) HOT 3
- [mac os] thread id is not the native_id
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.