lundi 26 janvier 2015

passing subprocess output to multiprocessing function


Vote count:

0




I'm trying two run the below to functions in parallel however one of the functions needs to be passed as a parameter to the other


Function 1:



def beginRecvTest():

incoming = Popen("receivetest -f=/pcan33".split(), stdout = PIPE)
processing = iter(incoming.stdout.readline, "")
lines = list(processing)
print processing
return lines


Function 2:



def readByLine():


i = 0
while (i < len(lines)):
system("clear")

if(lines[i][0].isdigit()):
line = lines[i].split()
dictAdd(line)
else:
next


print ; print "-" *80
for _i in mydict.keys():
printMsg(mydict, _i)

print "Keys: ", ; print mydict.keys()
print ; print "-" *80
sleep(0.3)
i += 1


Function call:



if __name__ == "__main__":

process1 = Process(target=beginRecvTest)
process1.start()
process2 = Process(target=readByLine, args=(process1,))
process2.start()
process1.join()
process2.join()


Unforunately I'm not sure how to pass this as a parameter and the code in process1 seems to hang at:



lines = list(processing)


for some reason, the program needs to pass the lines that have already been read into a list to process2 whilst still reading and sorting in process1.


Can anybody help?



asked 1 min ago







passing subprocess output to multiprocessing function

Aucun commentaire:

Enregistrer un commentaire