/head: changeset 100

Updated with some more bug fixes
This commit is contained in:
jgoerzen 2002-07-11 10:42:27 +01:00
parent 3e6b420c58
commit 387ab29841
3 changed files with 15 additions and 10 deletions

View File

@ -46,7 +46,7 @@ def threadsreset(threadlist):
###################################################################### ######################################################################
exitcondition = Condition(Lock()) exitcondition = Condition(Lock())
exitthread = None exitthreads = []
inited = 0 inited = 0
def initexitnotify(): def initexitnotify():
@ -55,7 +55,7 @@ def initexitnotify():
This SHOULD be called before the main thread starts any other This SHOULD be called before the main thread starts any other
ExitNotifyThreads, or else it may miss the ability to catch the exit ExitNotifyThreads, or else it may miss the ability to catch the exit
status from them!""" status from them!"""
exitcondition.acquire() pass
def exitnotifymonitorloop(callback): def exitnotifymonitorloop(callback):
"""Enter an infinite "monitoring" loop. The argument, callback, """Enter an infinite "monitoring" loop. The argument, callback,
@ -67,19 +67,21 @@ def exitnotifymonitorloop(callback):
an ExitNotifyThread, or else an infinite loop may result. Furthermore, an ExitNotifyThread, or else an infinite loop may result. Furthermore,
the monitor will hold the lock all the while the other thread is waiting. the monitor will hold the lock all the while the other thread is waiting.
""" """
global exitcondition, exitthread global exitcondition, exitthreads
while 1: # Loop forever. while 1: # Loop forever.
while exitthread == None: exitcondition.acquire()
while not len(exitthreads):
exitcondition.wait(1) exitcondition.wait(1)
callback(exitthread)
exitthread = None
while len(exitthreads):
callback(exitthreads.pop())
exitcondition.release()
class ExitNotifyThread(Thread): class ExitNotifyThread(Thread):
"""This class is designed to alert a "monitor" to the fact that a thread has """This class is designed to alert a "monitor" to the fact that a thread has
exited and to provide for the ability for it to find out why.""" exited and to provide for the ability for it to find out why."""
def run(self): def run(self):
global exitcondition, exitthread global exitcondition, exitthreads
self.threadid = thread.get_ident() self.threadid = thread.get_ident()
try: try:
Thread.run(self) Thread.run(self)
@ -94,7 +96,7 @@ class ExitNotifyThread(Thread):
if not hasattr(self, 'exitmessage'): if not hasattr(self, 'exitmessage'):
self.setExitMessage(None) self.setExitMessage(None)
exitcondition.acquire() exitcondition.acquire()
exitthread = self exitthreads.append(self)
exitcondition.notify() exitcondition.notify()
exitcondition.release() exitcondition.release()

View File

@ -175,6 +175,9 @@ class TkUI(UIBase):
s.top.destroy() s.top.destroy()
TextOKDialog("Main Program Exception", msg) TextOKDialog("Main Program Exception", msg)
def deletingmessages(s, uidlist, destlist):
ds = s.folderlist(destlist)
s._msg("Deleting %d messages in %s" % (len(uidlist), ds))
################################################## Copied from TTY ################################################## Copied from TTY

View File

@ -156,7 +156,7 @@ class UIBase:
Return 0 for normal sleep, or 1 to indicate a request Return 0 for normal sleep, or 1 to indicate a request
to sync immediately.""" to sync immediately."""
s._msg("Next refresh in %d seconds" % remainingsec) s._msg("Next refresh in %d seconds" % remainingsecs)
if sleepsecs > 0: if sleepsecs > 0:
time.sleep(sleepsecs) time.sleep(sleepsecs)
return 0 return 0