threading+popen2 hang

L

lofic

Hello,

I've seen many messages and bug reports on popen2 about pipes, buffer
size problems, sub-processes not properly closed, race conditions,
popen2 not being thread safe... But I still can't figure what applies
to my case.

This piece of code:

#!/usr/bin/python
import threading
import popen2

class MyThread ( threading.Thread ):
def run ( self ):
#popenChild = popen2.Popen3("cat /etc/passwd")
#popenChild = popen2.Popen3("/usr/bin/iostat -V")
popenChild = popen2.Popen3("/usr/bin/iostat -k -x 1 2")
popenChild.wait()
print 'Bye'

MyThread().start()


Works fine on RHEL5/python 2.4.3
Hangs on RHEL4/python 2.3.4

I presume it hangs on wait().

It does not hang with:
popenChild = popen2.Popen3("/usr/bin/iostat -V") # short output
popenChild = popen2.Popen3("cat /etc/passwd") # long output

It does not hang outside of a thread:
#!/usr/bin/python
import popen2
popenChild = popen2.Popen3("/usr/bin/iostat -k -x 1 2")
#print popenChild.fromchild.readlines()
popenChild.wait()
print 'Bye'


Could someone explain this to me ?

Thanks in advance.

Louis Coilliot
 
A

Aahz

Works fine on RHEL5/python 2.4.3
Hangs on RHEL4/python 2.3.4

Then use Python 2.4 -- surely you don't expect anyone to provide bugfixes
for a release that's several years old?
 
L

lofic

Then use Python 2.4 -- surely you don't expect anyone to provide bugfixes
for a release that's several years old?


2.3 is the version provided with RHEL 4, which is still widely used in
production environments. Sometimes it is not so easy to shift to
another version in production systems.
Some people don't work with the last bleeding edge Fedora release and
must deal with (sometimes pretty old) existing system pools.
I could deploy python 2.4 in addition to python 2.3, but it is much
shake up for a little bug and a little program.
I was not expected a bugfix, but maybe a workaround.

Louis
 
A

Aahz

2.3 is the version provided with RHEL 4, which is still widely used in
production environments. Sometimes it is not so easy to shift to
another version in production systems.

Believe me, I'm well aware of that (my last job was also stuck on 2.3).
Nevertheless, the pool of people familiar with the minutiae of bugs for
both Python 2.3 and 2.4 is dwindling daily, and your best recourse is
intensive Googling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top