Can't Delete a Thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • flamesrock

    #1

    Can't Delete a Thread

    I have the following two threads, called from a method:

    def uploading_regio n:
    uploading_regio n =
    AddRegionToServ erThread(self,s elf.SESSION,cre ate_region)
    while uploading_regio n.UPLOADING:
    pass
    #escape method when uploading_regio n thread is false

    class AddRegionToServ erThread(Thread ):
    def __init__(self, window, session, dict):
    Thread.__init__ (self)
    self.SESSION = session
    self.DICT = dict #contains dbuser,password , etc
    self.STATUS = 'Uploading the region. Please wait...'
    self.WINDOW = window
    self.dlg = wx.ProgressDial og('Please Wait...', self.STATUS,
    100, self.WINDOW, wx.PD_AUTO_HIDE | wx.PD_APP_MODAL )
    self.RETICULATE = ReticulateSplin es(self.dlg)
    self.UPLOADING = True
    self.start()

    def run(self):
    self.STATUS = 'Adding cities to database. Almost done...'
    #create database
    ....
    self.RETICULATE ._Thread__delet e()
    time.sleep(3) #give some extra time
    self.UPLOADING = False

    class ReticulateSplin es(Thread):
    def __init__(self,d ialog):
    Thread.__init__ (self)
    self.random_mes sages=[
    'reticulating splines','hirin g code monkeys','are you still
    watching this?',
    'a penny saved is a penny earned','use this as an
    opportunity to go outside',
    'mmm water','drinkin g decaff coffee','neuter ing excess
    bits',
    'starting improbability drive','delousi ng edmontonians']
    self.dialog = dialog
    self.x=1
    self.start()

    def run(self):
    self.x += 2

    self.dialog.Upd ate(self.x,self .random_message s[random.randrang e(len(self.rand om_messages))])
    time.sleep(3)
    self.__init__(s elf.dialog)




    Now for some reason, I can't delete the thread 'ReticulateSpli nes' in
    the run() function of AddRegionToServ erThread(). I call it, but the
    dialog window doesn't actually close, while, for some reason I am able
    to terminate AddRegionToServ erThread.

    Any ideas on why? I've tried a combination of things and yet nothing
    works.

    Any help would be greatly appreciated.

    -Thanks
    Flamesrock

Working...