wxpython GUI and multiprocessing - how to send data back from the long running process

Posted by wxpydon on Stack Overflow See other posts from Stack Overflow or by wxpydon
Published on 2010-05-18T07:50:25Z Indexed on 2010/05/19 6:00 UTC
Read the original article Hit count: 321

Hello everyone,

Trying to run a time consuming task from a wxpython GUI. The basic idea is to start the long time task from the GUI (pressing a button) and then, a static text on the dialog should be updated from it.

First I tried some threading (http://wiki.wxpython.org/LongRunningTasks and many other resourses seen), and I want to show back the messages using Publisher.class. It didn't went so well, after a message or two, the GUI seems to frozen.

Now I want to achieve that with multiprocessing. I have this method inside my 'GUI' class:

        def do_update(self, e):
            self.txt_updatemsg.SetLabel("Don't stop this \n")
            ...

            pub = Publisher() # i tried also calling directly from dbob object
            # Publisher() is a singleton so this must be useless?
            pub.subscribe(self.__update_txt_message, ('updatedlg', 'message'))

            dbob = dbutils.DBUtils() # DBUtils is the class with 'long time' tasks
            dbob.publisher = pub

            p = Process(target=self.do_update_process, args=(dbob,))
            p.start()
            while p.is_alive:
                wx.Yield

        def do_update_process(self, dbob):
            dbob.do_update()

__update_txt_message is a simple function what sets the static text on dialog.

Question is: how can I send back some text messages from this Process (just simple text, that's all I need) Thanks guys!

© Stack Overflow or respective owner

Related posts about wxpython

Related posts about multiprocessing