threading: add comments

Simplify the code.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-05-12 04:27:34 +02:00
parent bf8bfbc872
commit 2611a0ba6a
3 changed files with 26 additions and 11 deletions

View File

@ -25,6 +25,9 @@ import os.path
import sys
from offlineimap.ui import getglobalui
NORMAL_EXIT = 'SYNCRUNNER_EXITED_NORMALLY'
######################################################################
# General utilities
######################################################################
@ -70,7 +73,7 @@ class threadlist:
finally:
self.lock.release()
def reset(self):
def wait(self):
while 1:
thread = self.pop()
if not thread:
@ -129,7 +132,7 @@ def threadexited(thread):
raise SystemExit
ui.threadException(thread) # Expected to terminate
sys.exit(100) # Just in case...
elif thread.exit_message == 'SYNCRUNNER_EXITED_NORMALLY':
elif thread.exit_message == NORMAL_EXIT:
return True
else:
ui.threadExited(thread)
@ -157,6 +160,8 @@ class ExitNotifyThread(Thread):
self._exit_stacktrace = None
def run(self):
"""Allow profiling of a run."""
global exitthreads
try:
if not ExitNotifyThread.profiledir: # normal case