Replace thread.get_ident()

Replace low-level thread.get_ident() with threading.currentThread().ident.
This works both in python2.6 and python3. (thread is renamed _thread and its
direct use is not recommended)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth
2012-02-05 12:34:27 +01:00
parent ba3a698a67
commit 03566b2037
3 changed files with 6 additions and 9 deletions

View File

@ -15,13 +15,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from threading import Lock, Thread, BoundedSemaphore
from threading import Lock, Thread, BoundedSemaphore, currentThread
try:
from Queue import Queue, Empty
except ImportError: # python3
from queue import Queue, Empty
import traceback
from thread import get_ident # python < 2.6 support
import os.path
import sys
from offlineimap.ui import getglobalui
@ -152,7 +151,6 @@ class ExitNotifyThread(Thread):
def run(self):
global exitthreads
self.threadid = get_ident()
try:
if not ExitNotifyThread.profiledir: # normal case
Thread.run(self)
@ -167,7 +165,7 @@ class ExitNotifyThread(Thread):
except SystemExit:
pass
prof.dump_stats(os.path.join(ExitNotifyThread.profiledir,
"%s_%s.prof" % (self.threadid, self.getName())))
"%s_%s.prof" % (self.ident, self.getName())))
except Exception as e:
# Thread exited with Exception, store it
tb = traceback.format_exc()