Can't Delete a Thread

Discussion in 'Python' started by flamesrock, Apr 7, 2006.

  1. flamesrock

    flamesrock Guest

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

    def uploading_region:
    uploading_region =
    AddRegionToServerThread(self,self.SESSION,create_region)
    while uploading_region.UPLOADING:
    pass
    #escape method when uploading_region thread is false

    class AddRegionToServerThread(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.ProgressDialog('Please Wait...', self.STATUS,
    100, self.WINDOW, wx.PD_AUTO_HIDE | wx.PD_APP_MODAL)
    self.RETICULATE = ReticulateSplines(self.dlg)
    self.UPLOADING = True
    self.start()

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

    class ReticulateSplines(Thread):
    def __init__(self,dialog):
    Thread.__init__(self)
    self.random_messages=[
    'reticulating splines','hiring code monkeys','are you still
    watching this?',
    'a penny saved is a penny earned','use this as an
    opportunity to go outside',
    'mmm water','drinking decaff coffee','neutering excess
    bits',
    'starting improbability drive','delousing edmontonians']
    self.dialog = dialog
    self.x=1
    self.start()

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

    self.dialog.Update(self.x,self.random_messages[random.randrange(len(self.random_messages))])
    time.sleep(3)
    self.__init__(self.dialog)




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

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

    Any help would be greatly appreciated.

    -Thanks
    Flamesrock
     
    flamesrock, Apr 7, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    658
    Chris \( Val \)
    Jul 22, 2003
  2. HeroOfSpielburg
    Replies:
    1
    Views:
    413
    Alf P. Steinbach
    Aug 6, 2003
  3. 0to60
    Replies:
    4
    Views:
    325
    Jerry Coffin
    Dec 19, 2003
  4. bearsprite
    Replies:
    3
    Views:
    612
    Dennis Lee Bieber
    Dec 12, 2006
  5. Replies:
    9
    Views:
    1,852
    Piet van Oostrum
    Jul 26, 2009
Loading...

Share This Page