[Tutor] multiprocessing for nested function

tax botsis taxbotsis at gmail.com
Tue May 17 16:29:24 CEST 2011


Part of my code includes the following script, which both shows a progress
bar (for as long as 'categorize_reports()' is executed) and prints the
fileid and the output of the 'document' function; the latter is the one
increasing the calculation time (please see my comment). Any ideas on how to
use all the cores of my CPU here?

...
def categorize_reports():
    if __name__ == '__main__':
        root2 = Tkinter.Tk(className=' Processing Progress')
        m = Meter(root2, relief='ridge', bd=3)
        m.pack(fill='x')
        i=0.0
        for fileid in fileids():
            m.set(i, 'Processing will take a few minutes...')
            i=i+1.000/len(fileids())
            m.after(1000, lambda: _demo(m, i))
            print str(fileid), document(fileid) #this slows down the process
        root2.withdraw()
...

Thanks
Tax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110517/471d21b6/attachment.html>


More information about the Tutor mailing list