subprocess communication, exec()

Chuckk Hubbard badmuthahubbard at gmail.com
Tue Nov 11 13:23:51 EST 2008


If I run 'python -i subprocessclient.py' I expect to see the nice
level of it go up 2, and the nice level of the subprocess go up 1.
But all I see is the nice level of the client change.  What am I doing
wrong?

subprocessserver.py:
----------------------------
#!/usr/bin/python2.5

import os
import sys

while True:
    next_line = sys.stdin.readline()
    if not next_line:
        break
    exec(next_line)
#    sys.stdout.write(output)
#    sys.stdout.write(next_line)
#    sys.stdout.flush()
----------------------------

subprocessclient.py:
----------------------------
#!/usr/bin/python2.5

import subprocess, os

server = subprocess.Popen(('python2.5', 'subprocessserver.py'),
shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

os.nice(2)

server.stdin.write('''os.nice(1)''')
----------------------------

Thanks.
-Chuckk

-- 
http://www.badmuthahubbard.com



More information about the Python-list mailing list