[PATCH] Simplify exit thread evaluation
Sebastian Spaeth
Sebastian at SSpaeth.de
Wed Dec 1 16:06:37 GMT 2010
Rather than sleeping for 1 second and poll our exitthread Queue in a
non-bloking fashion simply call it in a blocking fashion. Works for
me, and is potentially somewhat faster as we don't do unnecessary
sleeps after a thread exited.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
offlineimap/threadutil.py | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py
index b516f68..579ef35 100644
--- a/offlineimap/threadutil.py
+++ b/offlineimap/threadutil.py
@@ -111,12 +111,10 @@ def exitnotifymonitorloop(callback):
the monitor will hold the lock all the while the other thread is waiting.
"""
global exitthreads
- while 1: # Loop forever.
- try:
- thrd = exitthreads.get(False)
- callback(thrd)
- except Empty:
- time.sleep(1)
+ while 1:
+ # Loop forever and call 'callback' for each thread that exited
+ thrd = exitthreads.get(True)
+ callback(thrd)
def threadexited(thread):
"""Called when a thread exits."""
--
1.7.1
More information about the OfflineIMAP-project
mailing list