threading : AttributeE​rror: 'NoneType' object has no attribute 'start'
I am new to the python and I need a small script to be written using threads which reads the specific files present in a directory and does some selections of lines and then write those lines into different files. However the error I am getting is: AttributeError: 'NoneType' object has no attribute 'start' Here is the code. Can somebody please help me. This is very urgent. def getFiles(fname): fname=preprocessLogFileDir + "/" + fname print fname fin = open(fname, "r") line=fin.readline() print line .... # some extraction logic. fout = open("out-single-file/1xx_2xx_total", "w") fout.write(line) fout.close() files=os.listdir(preprocessLogFileDir) cnt=1; for fname in files: print fname if fnmatch.fnmatch(fname,'*.log'): #and os.path.isfile(fname): thr = "thr" + str(cnt) print thr thr=getFiles(fname) thr.start() thr.join cnt = cnt + 1 else: print "\npreprocessLogFileDir/fname is either a directory or does not end with 'log'." print "Probabally not a pre-process file. Ignoring the file.\n\n"
participants (4)
-
C. Titus Brown
-
Sagar Neve
-
Stefan Behnel
-
Tim Lesher