[Python-ideas] threading : AttributeE???rror: 'NoneType' object has no attribute 'start'
nevesagar at gmail.com
Wed Sep 14 05:33:31 CEST 2011
Thanks. This is been resolved. Will take care of this in future.
On Mon, Sep 12, 2011 at 8:30 AM, C. Titus Brown <ctb at msu.edu> wrote:
> On Sun, Sep 11, 2011 at 07:54:28PM -0700, Sagar Neve wrote:
> > 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'
> [ ... ]
> Hi Sagar,
> this isn't the right place to post questions about how to use Python --
> this is
> python-ideas, a list for discussing future changes to the language. Please
> go to
> with future requests for help.
> > Here is the code. Can somebody please help me. This is very urgent.
> ...and note that your urgency is not ours, since you're not paying us!
> That having been said, at least one source of your problems is that
> 'getFiles' doesn't return a value. It's kind of hard to figure out what
> you want it to do; 'thr.start()' followed by 'thr.join()' immediately isn't
> going to result in much threading, unless there's more going on here than
> meets the eye.
> You might want to use something like
> thr = threading.Thread(target=getFiles)
> instead. See
> And please ask future questions elsewhere.
> > 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"
> > _______________________________________________
> > Python-ideas mailing list
> > Python-ideas at python.org
> > http://mail.python.org/mailman/listinfo/python-ideas
> C. Titus Brown, ctb at msu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas