2015-01-08 3 views
0

이전 질문의 프로그램을 다시 쓰고 있는데 문제가 있습니다. 참조하시기 바랍니다 코드 :TypeError : Popen not iterable

#!/usr/bin/python 

import subprocess,time, timeit 
from multiprocessing import Process, Queue 
import re, os, pprint, math 
from collections import defaultdict 

Dict = {} 
identifier = "" 
hexbits = [] 
count = defaultdict(int) 

def __ReadRX__(RX_info): 
    lines = iter(RX_info.stdout.readline, "") 
    try: 
     start = time.clock() 
     for line in lines: 
      if re.match(r"^\d+.*$",line): 
       splitline = line.split() 
       del splitline[1:4] 
       identifier = splitline[1] 
       count[identifier] += 1 
       end = time.clock() 
       timing = round((end - start) * 10000, 100) 
       dlc = splitline[2] 
       hexbits = splitline[3:] 
       Dict[identifier] = [dlc, hexbits, count[identifier],int(timing)] 
       start = end 
    except keyboardinterrupt: 
     pass 

procRX = subprocess.Popen('receivetest -f=/dev/pcan32'.split(), stdout=subprocess.PIPE) 

if __name__ == '__main__': 
    munchCan = Process(target=__ReadRX__, args=(procRX)) 
    munchCan.start() 
    munchCan.join() 
    print Dict 

나는 다음과 같은 오류 코드 실행하려고 : 나는 서브 프로세스를 구분하고 별도의 프로세스로 __ReadRX__을 설정하기 전에이 코드는 일

File "./cancheck2.py", line 36, in <module> 
    munchCan = Process(target=__ReadRx__, args=(procRX)) 
File "/usr/lib/python2.7/multiprocessing/process.py", line 104, in __init__ 
    self._args = tuple(args) 
TypeError: 'Popen' objec is not iterable 

합니다.

내가 이해하지 못하기 때문에 아무도 무슨 일이 일어나고 있는지 설명하지 않습니까?

답변

2

(procRX) 튜플을 만들지 않으려면 (procRX,)을 사용해야합니다.

+0

나는 바보 야 .... 고마워! – Jalcock501