diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index bfe3796..e5c9c18 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -19,7 +19,7 @@ from offlineimap import imaplibutil, imaputil, threadutil, OfflineImapError from offlineimap.ui import getglobalui from threading import Lock, BoundedSemaphore -import thread +from thread import get_ident # python < 2.6 support import time import hmac import socket @@ -167,11 +167,10 @@ class IMAPServer: # Try to find one that previously belonged to this thread # as an optimization. Start from the back since that's where # they're popped on. - threadid = thread.get_ident() imapobj = None for i in range(len(self.availableconnections) - 1, -1, -1): tryobj = self.availableconnections[i] - if self.lastowner[tryobj] == threadid: + if self.lastowner[tryobj] == get_ident(): imapobj = tryobj del(self.availableconnections[i]) break @@ -179,7 +178,7 @@ class IMAPServer: imapobj = self.availableconnections[0] del(self.availableconnections[0]) self.assignedconnections.append(imapobj) - self.lastowner[imapobj] = thread.get_ident() + self.lastowner[imapobj] = get_ident() self.connectionlock.release() return imapobj @@ -266,7 +265,7 @@ class IMAPServer: self.connectionlock.acquire() self.assignedconnections.append(imapobj) - self.lastowner[imapobj] = thread.get_ident() + self.lastowner[imapobj] = get_ident() self.connectionlock.release() return imapobj except Exception, e: diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py index cef2195..fe4b5fd 100644 --- a/offlineimap/threadutil.py +++ b/offlineimap/threadutil.py @@ -19,7 +19,7 @@ from threading import Lock, Thread, BoundedSemaphore from Queue import Queue, Empty import traceback -import thread +from thread import get_ident # python < 2.6 support import sys from offlineimap.ui import getglobalui @@ -149,7 +149,6 @@ class ExitNotifyThread(Thread): exited and to provide for the ability for it to find out why.""" def run(self): global exitthreads, profiledir - self.threadid = thread.get_ident() try: if not profiledir: # normal case Thread.run(self) @@ -164,7 +163,7 @@ class ExitNotifyThread(Thread): except SystemExit: pass prof.dump_stats( \ - profiledir + "/" + str(self.threadid) + "_" + \ + profiledir + "/" + str(get_ident()) + "_" + \ self.getName() + ".prof") except: self.setExitCause('EXCEPTION') diff --git a/offlineimap/ui/Blinkenlights.py b/offlineimap/ui/Blinkenlights.py index 257dca2..2160100 100644 --- a/offlineimap/ui/Blinkenlights.py +++ b/offlineimap/ui/Blinkenlights.py @@ -18,7 +18,7 @@ from threading import RLock, currentThread from offlineimap.ui.UIBase import UIBase -import thread +from thread import get_ident # python < 2.6 support class BlinkenBase: """This is a mix-in class that should be mixed in with either UIBase @@ -103,7 +103,7 @@ class BlinkenBase: UIBase.threadExited(s, thread) def gettf(s): - threadid = thread.get_ident() + threadid = get_ident() accountname = s.getthreadaccount() s.tflock.acquire()