Change in vdsm[master]: mailbox: Use threading instead of thread

nsoffer at redhat.com nsoffer at redhat.com
Mon May 18 13:32:19 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: mailbox: Use threading instead of thread
......................................................................

mailbox: Use threading instead of thread

SPM MailMonitor thread was created using the thread.start_new_thread.
This creates a thread with the unhelpful name "Dummy-1234". Also the
locks used by this thread were created using thread.allocate_lock().

I'm not aware of any advantages of using the lower level thread module,
and searching vdsm history back to 2009 does not show any clue why this
code was used.

Now we use the threading module used for all other threads and locks in
vdsm. This allows more helpful thread names in the next patches.

Change-Id: I17a486dab5d6355cfd35f1618b96d25ce454dff2
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/storage_mailbox.py
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/41061/1

diff --git a/vdsm/storage/storage_mailbox.py b/vdsm/storage/storage_mailbox.py
index fd4636a..1ad599b 100644
--- a/vdsm/storage/storage_mailbox.py
+++ b/vdsm/storage/storage_mailbox.py
@@ -18,7 +18,6 @@
 # Refer to the README and COPYING files for full details of the license
 #
 
-import thread
 import os
 import errno
 import time
@@ -570,8 +569,8 @@
                         'conv=notrunc',
                         'count=1'
                         ]
-        self._outLock = thread.allocate_lock()
-        self._inLock = thread.allocate_lock()
+        self._outLock = threading.Lock()
+        self._inLock = threading.Lock()
         # Clear outgoing mail
         self.log.debug("SPM_MailMonitor - clearing outgoing mail, command is: "
                        "%s", self._outCmd)
@@ -581,7 +580,9 @@
             self.log.warning("SPM_MailMonitor couldn't clear outgoing mail, "
                              "dd failed")
 
-        thread.start_new_thread(self.run, (self, ))
+        t = threading.Thread(target=self.run)
+        t.daemon = True
+        t.start()
         self.log.debug('SPM_MailMonitor created for pool %s' % self._poolID)
 
     def stop(self):
@@ -781,7 +782,7 @@
 
     @utils.traceback(on=log.name,
                      msg="Unhandled exception in SPM_MailMonitor thread")
-    def run(self, *args):
+    def run(self):
         try:
             while not self._stop:
                 try:


-- 
To view, visit https://gerrit.ovirt.org/41061
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17a486dab5d6355cfd35f1618b96d25ce454dff2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list