Can't Delete a Thread

F

flamesrock

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top