Hi,

I'm trying to create a Tkinter application that uses multiprocessing in
a separate module to do some work.

In the Tkinter part I have this method of my Window ttk.Frame subclass:

    def report(self, future):
        with StatusLock: # Serialize calls to Window.report()
            if future.exception() is None:
                result = future.result()
                print(result)
# TODO why does this lock the application?
                self.statusText.set(result.name)
                self.master.update() # Make sure the GUI refreshes

StatusLock is a multiprocessing.Lock.
self.statusText is a tk.StringVar.

This function is called by a multiprocessing Future:

    future = executor.submit(action, arg1, arg2)
    future.add_done_callback(report)

When I run the program with the last two lines of report() commented out
it correctly prints each result on the console. But with the last two
lines uncommented it prints one result and then the whole application
locks at the self.statusText.set() call.

According to the multiprocessing docs the callback is executed in the
thread of the function it is passed -- so in this case in the GUI thread
which is what is wanted.

Any suggestions/help welcome:-)

Thanks!

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to