Verfasst: Dienstag 24. Januar 2006, 14:09
Ach doch... jetzt scheint es zu gehen... Hab mal aus newdata nur data gemacht und einen counter eingebaut... Zumindest in der Konsole geht's richtig:
test1.py
test2.py
In SciTE kommt reproduzierbar dieses:Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 1]
Subprocess started!
Received in subprocess: ['Counter1:', 0, 'Counter2:', 1]
Got data from subprocess: ['Counter1:', 1, 'Counter2:', 1]
Writing data to subprocess: ['Counter1:', 1, 'Counter2:', 2]
Received in subprocess: ['Counter1:', 1, 'Counter2:', 2]
Got data from subprocess: ['Counter1:', 2, 'Counter2:', 2]
Writing data to subprocess: ['Counter1:', 2, 'Counter2:', 3]
Received in subprocess: ['Counter1:', 2, 'Counter2:', 3]
Got data from subprocess: ['Counter1:', 3, 'Counter2:', 3]
Writing data to subprocess: ['Counter1:', 3, 'Counter2:', 4]
Received in subprocess: ['Counter1:', 3, 'Counter2:', 4]
Got data from subprocess: ['Counter1:', 4, 'Counter2:', 4]
Writing data to subprocess: ['Counter1:', 4, 'Counter2:', 5]
Received in subprocess: ['Counter1:', 4, 'Counter2:', 5]
Got data from subprocess: ['Counter1:', 5, 'Counter2:', 5]
Writing data to subprocess: ['Counter1:', 5, 'Counter2:', 6]
Received in subprocess: ['Counter1:', 5, 'Counter2:', 6]
Got data from subprocess: ['Counter1:', 6, 'Counter2:', 6]
Writing data to subprocess: ['Counter1:', 6, 'Counter2:', 7]
Received in subprocess: ['Counter1:', 6, 'Counter2:', 7]
Got data from subprocess: ['Counter1:', 7, 'Counter2:', 7]
Writing data to subprocess: ['Counter1:', 7, 'Counter2:', 8]
Received in subprocess: ['Counter1:', 7, 'Counter2:', 8]
Got data from subprocess: ['Counter1:', 8, 'Counter2:', 8]
Writing data to subprocess: ['Counter1:', 8, 'Counter2:', 9]
Received in subprocess: ['Counter1:', 8, 'Counter2:', 9]
Got data from subprocess: ['Counter1:', 9, 'Counter2:', 9]
Writing data to subprocess: ['Counter1:', 9, 'Counter2:', 10]
Received in subprocess: ['Counter1:', 9, 'Counter2:', 10]
Got data from subprocess: ['Counter1:', 10, 'Counter2:', 10]
Parent has closed connection. Terminating.
Closed stdin and out for subprocess. Terminating.
Hier mal der modizifierte Code:Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 1]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 1]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 2]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 2]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 3]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 3]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 4]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 4]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 5]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 5]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 6]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 6]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 7]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 7]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 8]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 8]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 9]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 9]
Writing data to subprocess: ['Counter1:', 0, 'Counter2:', 10]
Got data from subprocess: ['Counter1:', 0, 'Counter2:', 10]
Closed stdin and out for subprocess. Terminating.
Subprocess started!
Received in subprocess: ['Counter1:', 0, 'Counter2:', 1]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 2]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 3]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 4]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 5]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 6]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 7]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 8]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 9]
Received in subprocess: ['Counter1:', 0, 'Counter2:', 10]
Parent has closed connection. Terminating.
test1.py
Code: Alles auswählen
import sys, pickle
# Daten lesen und gleich wieder dumpen.
sys.stderr.write("Subprocess started!\n")
while True:
try:
data = pickle.load(sys.stdin)
sys.stderr.write("Received in subprocess: %r\n" % data)
except EOFError:
sys.stderr.write("Parent has closed connection. Terminating.\n")
break
data[1] = data[1] + 1 # verändern des Counter1
pickle.dump(data,sys.stdout, protocol=pickle.HIGHEST_PROTOCOL)
sys.stdout.flush()
Code: Alles auswählen
import sys, pickle, subprocess
proc = subprocess.Popen(["python","test1.py"],0,None,
subprocess.PIPE,subprocess.PIPE,None,
universal_newlines=True)
data = ["Counter1:",0,"Counter2:",0]
for in range(10):
data[3] = data[3] + 1 # verändern des Counter2
print "Writing data to subprocess:", data
pickle.dump(data,proc.stdin, protocol=pickle.HIGHEST_PROTOCOL)
data = pickle.load(proc.stdout)
print "Got data from subprocess:", data
proc.stdin.close()
proc.stdout.close()
print "Closed stdin and out for subprocess. Terminating."