Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
giampaolo opened this issue May 23, 2014 · 8 comments
Closed
Assignees

Comments

@giampaolo
Copy link
Owner

From A.Ma...@gmail.com on August 08, 2011 23:18:12

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: http://code.google.com/p/psutil/issues/detail?id=193

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on September 16, 2011 08:34:19

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)

@giampaolo
Copy link
Owner Author

From g.rodola on March 09, 2012 05:08:46

This should now be fixed as r1277 .

Status: FixedInSVN
Owner: g.rodola
Labels: Milestone-0.5.0

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2012 11:54:03

0.5.0 is finally out. Closing out as fixed.

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:02:23

Updated csets after the SVN -> Mercurial migration: r1277 == revision 
f5120b145d09

@giampaolo
Copy link
Owner Author

From robert.a...@gmail.com on December 28, 2013 11:32:19

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.

@giampaolo
Copy link
Owner Author

From g.rodola on December 30, 2013 05:14:38

Status: ReOpened

@giampaolo
Copy link
Owner Author

From g.rodola on December 31, 2013 03:29:30

Fixed in revision 4d5f5e2fa969 .

Status: FixedInHG
Labels: Milestone-1.3.0

@giampaolo
Copy link
Owner Author

From g.rodola on March 10, 2014 04:36:50

Closing out as fixed as 2.0.0 version is finally out.

Status: Fixed
Labels: -Milestone-0.5.0 -Milestone-1.3.0 Milestone-2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant