On Sep 22, 11:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Let's say I have this Python file called loop.py: > > import sys > print 'hi' > sys.stdout.flush() > while 1: > pass > > And I want to call it from another Python process and read the value > 'hi'. How would I do it? > > So far I have tried this: > > >>> proc = subprocess.Popen('python > >>> /home/chiefinnovator/loop.py',shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) > >>> proc.stdout.read() > > But it just hangs at read() > > proc.communicate() also just hangs. What am I doing wrong? Please > advise.
Well, using this subclass of subprocess.Popen fixes the problem (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554) I don't understand how it works though. Would anyone mind explaining? I'm thinking there's something fundamental about Unix processes I'm not understanding. -Greg -- http://mail.python.org/mailman/listinfo/python-list