Running a program from another program.

Laurent Verweijen somelauw at gmail.com
Thu Jun 17 16:42:55 EDT 2010


Op donderdag 17-06-2010 om 13:01 uur [tijdzone -0700], schreef Stephen
Hansen: 
> On 6/17/10 12:13 PM, Laurent Verweijen wrote:
> > How do I make sure the inputstream stays open after the first call to
> > communicate?
> 
> This was just asked a few days ago in different words-- check out the
> thread, a couple solutions are offered. In short, you need to make
> stdin/stdout non-blocking:
> 
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/066de1c0fd38642f#
> 

I tried putting what Ian Kelly said in my code, by it doesn't work for
me.

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import fcntl
>>> import subprocess
>>> process = subprocess.Popen(["python", "increment.py"], stdin =
subprocess.PIPE, stdout = subprocess.PIPE)
>>> flags = fcntl.fcntl(process.stdout, fcntl.F_GETFL)
>>> fcntl.fcntl(process.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
0
>>> process.stdin.write("5\n")
>>> process.stdout.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 11] Resource temporarily unavailable




More information about the Python-list mailing list