[PATCH 1/4] threading: simplify names

Nicolas Sebrecht nicolas.s-dev at laposte.net
Tue May 17 01:45:57 BST 2016


Improve comments.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev at laposte.net>
---
 offlineimap/init.py       | 2 +-
 offlineimap/syncmaster.py | 9 +++++----
 offlineimap/threadutil.py | 6 +++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/offlineimap/init.py b/offlineimap/init.py
index 8fdbde7..1e2917e 100644
--- a/offlineimap/init.py
+++ b/offlineimap/init.py
@@ -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)
diff --git a/offlineimap/syncmaster.py b/offlineimap/syncmaster.py
index 7112548..5682798 100644
--- a/offlineimap/syncmaster.py
+++ b/offlineimap/syncmaster.py
@@ -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.
diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py
index 1e385b8..02692a1 100644
--- a/offlineimap/threadutil.py
+++ b/offlineimap/threadutil.py
@@ -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)
-- 
2.7.4





More information about the OfflineIMAP-project mailing list