Python/wxPython: Doing work continuously in the background?

I would use a threading. Thread to run the code in the background and wx. CallAfter to post updates to my window thread to render them to the user.

I would use a threading. Thread to run the code in the background and wx. CallAfter to post updates to my window thread to render them to the user.

Thread = threading. Thread(target=self. Do_work) thread.

SetDaemon(True) thread.start() ... def do_work(self): # processing code here while processing: # do stuff wx. CallAfter(self. Update_view, args, kwargs) def update_view(self, args): # do stuff with args # since wx.

CallAfter was used, it's safe to do GUI stuff here.

Launch a new process to render in background and periodically check to see if it has returned. You can find the documentation for the subprocess module here and the multiprocess module here. As Jay said, multiprocess is probably better if you're using Python 2.6.That said, I don't think there would be any performance difference between the two.

Multiprocess just seems to be a wrapper around subprocess making certain things easier to do. While subprocess/multiprocess is the standard way to do this, you may also want to take a look at Parallel Python.

I've never worked with multiple processes before. Where do I start? Also, I understood there are different ways of doing it.

Which one should I choose? – Ram Rachum Apr 8 '09 at 16:04 N.B., keep in mind that since this is a program for doing simulations, performance is very important. – Ram Rachum Apr 8 '09 at 16:04 If you can use python 2.6, I believe the multiprocessing module would be the standard way of accomplishing this.It should give you just as much performance as your OS and hardware has to provide.

– Jay Kominek Apr 8 '09 at 16:07 FYI if you're using Windows with wxPython, it's better to use 2.5 lists.wxwidgets. Org/pipermail/wxpython-users/2009-March/… – DrBloodmoney Apr 8 '09 at 16:40 I also heard about Stackless Python.Is it relevant? Is it better than subprocess/multiprocess?

– Ram Rachum Apr 8 '09 at 17:05.

There's a fair bit of info on the wxPython wiki about long running tasks that might be useful. They basically make use a thread and wx. PostEvent to handle communication between the thread and the main wx event loop.

If you don't mind using a very slightly different approach, you can have a look at stackless python and create a tasklet for your rendering process. I find it very easy to use personally.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions