nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Popen constructor throws an exception instead of creating an object #193

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Rarely psutil raises NoSuchProcess exception in psutil.Popen constructor.  It 
can crash with everything as Popen.__init__ args.

What is the expected output? What do you see instead?

args = ['program.exe'], stdout = stdin = stderr = env = None
Bottom of call stack:
  File "C:\please\please\please\executors\runner.py", line 65, in run
    process = psutil.Popen(args, stdout = stdout_fh, stdin = stdin_fh, stderr = stderr_fh, env = env)
  File "C:\Python32\lib\site-packages\psutil\__init__.py", line 524, in __init__
    Process.__init__(self, self.__subproc.pid)
  File "C:\Python32\lib\site-packages\psutil\__init__.py", line 101, in __init__
    raise NoSuchProcess(pid, None, "no process found with pid %s" % pid)
psutil.error.NoSuchProcess: no process found with pid 2016

I expected creating of Popen object, instead I catch an exception. The only 
solution to me is to create Popen object again and again until it works 
properly.

What version of psutil are you using? What Python version?

Python 3.2.1, psutil-0.3.0.

On what operating system? Is it 32bit or 64bit version?

Windows XP 32-bit

Please provide any additional information below.

Same problem appears on different Windows version, i've seen it under WinXP 
64-bit, Win7 32-bit and Win7 64-bit. But under *NIX everything is ok.

Original issue reported on code.google.com by A.Ma...@gmail.com on 8 Aug 2011 at 9:18

GoogleCodeExporter commented 8 years ago
What's "program.exe"? 
Maybe it's a program which starts and terminates so quickly that at the time 
Process.__init__ is invoked (after subproces.Popen) the process is already gone.
If not, does it change anything if you put a sleep() between the two calls like 
this?

class Popen(Process):

    def __init__(self, *args, **kwargs):
        self.__subproc = subprocess.Popen(*args, **kwargs)
        time.sleep(.2)
        Process.__init__(self, self.__subproc.pid)

Original comment by g.rodola on 16 Sep 2011 at 3:34

GoogleCodeExporter commented 8 years ago
This should now be fixed as r1277.

Original comment by g.rodola on 9 Mar 2012 at 1:08

GoogleCodeExporter commented 8 years ago
0.5.0 is finally out. Closing out as fixed.

Original comment by g.rodola on 27 Jun 2012 at 6:54

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r1277 == revision f5120b145d09

Original comment by g.rodola on 2 Mar 2013 at 12:02

GoogleCodeExporter commented 8 years ago
I can reproduce it in 1.2.1 in FreeBSD. E.g.

psutil.Popen(shlex.split("cpuset -c -l 1-1 -p 12322"), stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)

throws

File "build/bdist.freebsd-9.1-RELEASE-p7-amd64/egg/psutil/__init__.py", line 
996, in __init__
psutil._error.NoSuchProcess: no process found with pid 51355

~ 1 time in 20 attempts.

Original comment by robert.a...@gmail.com on 28 Dec 2013 at 7:32

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 30 Dec 2013 at 1:14

GoogleCodeExporter commented 8 years ago
Fixed in revision 4d5f5e2fa969.

Original comment by g.rodola on 31 Dec 2013 at 11:29

GoogleCodeExporter commented 8 years ago
Closing out as fixed as 2.0.0 version is finally out.

Original comment by g.rodola on 10 Mar 2014 at 11:36