threading: simplify names

Improve comments.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-05-17 02:04:48 +02:00
parent 23f96ba880
commit 9f8aa38d62
3 changed files with 9 additions and 8 deletions

View File

@ -392,7 +392,7 @@ class OfflineImap:
name='Sync Runner',
kwargs={'accounts': syncaccounts, 'config': self.config})
t.start()
threadutil.exitnotifymonitorloop()
threadutil.monitor()
if not options.dryrun:
offlineimap.mbnames.write(True)

View File

@ -16,7 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from offlineimap.threadutil import threadlist, InstanceLimitedThread, NORMAL_EXIT
from offlineimap.threadutil import threadlist, InstanceLimitedThread, STOP_MONITOR
from offlineimap.accounts import SyncableAccount
from threading import currentThread
@ -32,10 +32,11 @@ def syncaccount(config, accountname):
return thread
def syncitall(accounts, config):
"""The target when in multithreading mode."""
"""The target when in multithreading mode for running accounts threads."""
# Special exit message for SyncRunner thread, so main thread can exit.
currentThread().exit_message = NORMAL_EXIT
# Special exit message for the monitor to stop looping so the main thread
# can exit.
currentThread().exit_message = STOP_MONITOR
threads = threadlist() # The collection of threads.
for accountname in accounts:
# Start a new thread per account and store it in the collection.

View File

@ -25,7 +25,7 @@ import os.path
from offlineimap.ui import getglobalui
NORMAL_EXIT = 'SYNCRUNNER_EXITED_NORMALLY'
STOP_MONITOR = 'STOP_MONITOR'
######################################################################
# General utilities
@ -86,7 +86,7 @@ class threadlist:
exitthreads = Queue()
def exitnotifymonitorloop():
def monitor():
"""An infinite "monitoring" loop watching for finished ExitNotifyThread's.
This one is supposed to run in the main thread.
@ -128,7 +128,7 @@ def exitnotifymonitorloop():
" and the ui did not stop the program."%
(repr(thread.exit_exception), type(thread.exit_exception)))
elif thread.exit_message == NORMAL_EXIT:
elif thread.exit_message == STOP_MONITOR:
break # Exit the loop here.
else:
ui.threadExited(thread)