[Tutor] [tutor] Question on multithreading

Varsha Purohit varsha.purohit at gmail.com
Sun Feb 24 00:53:33 CET 2008


Hello,
    i have a gui program in wxpython where i am spawning two threads. one
for the mainloop of gui and other for some background tasks. I have to stop
the background running thread once its work is done. I am trying to use the
join method but it is giving me an error saying threads cannot be joined as
the thread has just been created... whereas at that point the thread is done
with its job. So i am confused whether i am putting it correctly or not.
also, is there any method called stop() to stop the threads....Also, i want
to see if the thread is alive or not.. but i donno where should i put the
isAlive() method associated with the thread.. i tried putting it in the code
where thread does execution but apparently it is not the correct
place.........

Here is the code...

class GuiScript(threading.Thread):
    def __init__(self):
        self.run()
    def run(self):
        app = wx.PySimpleApp()
        MainWindow().Show()
        app.MainLoop()

class RunScript(threading.Thread):
    def run(self):
        imFile=test()

and when the stop button is pressed the two threads should stop executing...
so i have written code like this...

def OnCloseWindow(self,event):
        GuiScript().Stop()
        RunScript().Stop()
        self.Destroy()

but seems stop() method is not existing... can anybody guide me plzzzz

thanks,


-- 
Varsha Purohit,
Graduate Student
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080223/48d66037/attachment.htm 


More information about the Tutor mailing list