When using a multithreading, I get combined data
The list is : A,B,C. If I MT this, the fdata [] contains data from A,B and C. How do I Get fdata too hold only one set of data. I tried del fdata didnt help. I need some kind of lock.
class WorkerThread(threading.Thread):
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queue
def run(self):
while 1:
try: # take a job from the queue
symbol, test, test2 = self.queue.get_nowait()
except Queue.Empty:
raise SystemExit
fn = %s.CSV" % symbol
fdata = []
fo = open(fn, 'rb')
fr = csv.reader(fo, dialect='excel')
for row in fr:
fdata.append(row)
#print fdata
#del fdata
How would I add the thread number to fdata or list id A,B,C to fdata?