]> granicus.if.org Git - python/commitdiff
fix more threading API related bugs
authorBenjamin Peterson <benjamin@python.org>
Fri, 13 Jun 2008 02:00:47 +0000 (02:00 +0000)
committerBenjamin Peterson <benjamin@python.org>
Fri, 13 Jun 2008 02:00:47 +0000 (02:00 +0000)
Lib/bsddb/test/test_associate.py
Lib/bsddb/test/test_join.py
Lib/bsddb/test/test_lock.py
Lib/bsddb/test/test_thread.py
Lib/idlelib/rpc.py
Lib/idlelib/run.py
Lib/socketserver.py
Lib/test/test_threadedtempfile.py
Lib/threading.py

index b9f250bbd76d1f29b235273df3d782b5ceae4cac..2876528ed4b04da0787252176fda63e53dcd31b3 100644 (file)
@@ -9,7 +9,7 @@ import time
 from pprint import pprint
 
 try:
-    from threading import Thread, currentThread
+    from threading import Thread, current_thread
     have_threads = 1
 except ImportError:
     have_threads = 0
index de674eeb7a61a0c8344e74aa5be8afd1e4941566..7addf4043d2beec152f4e107c1929ba3be5bc92f 100644 (file)
@@ -8,7 +8,7 @@ import time
 from pprint import pprint
 
 try:
-    from threading import Thread, currentThread
+    from threading import Thread, current_thread
     have_threads = 1
 except ImportError:
     have_threads = 0
index 5baba6912891e0ef6dc88ae11601610ab7552933..0467d834d559250dc569611a812bbf58db93d359 100644 (file)
@@ -7,7 +7,7 @@ import tempfile
 import time
 
 try:
-    from threading import Thread, currentThread
+    from threading import Thread, current_thread
     have_threads = 1
 except ImportError:
     have_threads = 0
@@ -117,7 +117,7 @@ class LockingTestCase(unittest.TestCase):
         deadlock_detection.end=False
         deadlock_detection.count=0
         t=Thread(target=deadlock_detection)
-        t.setDaemon(True)
+        t.set_daemon(True)
         t.start()
         self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
         anID = self.env.lock_id()
@@ -143,7 +143,7 @@ class LockingTestCase(unittest.TestCase):
             self.assertTrue(deadlock_detection.count>0)
 
     def theThread(self, sleepTime, lockType):
-        name = currentThread().getName()
+        name = current_thread().get_name()
         if lockType ==  db.DB_LOCK_WRITE:
             lt = "write"
         else:
index e39124eaf62ab4a4728585d59524acf440d77d05..85d77365004f26db0f7d7fd52cd42ace034d3ceb 100644 (file)
@@ -12,7 +12,7 @@ from random import random
 DASH = b'-'
 
 try:
-    from threading import Thread, currentThread
+    from threading import Thread, current_thread
     have_threads = True
 except ImportError:
     have_threads = False
@@ -89,20 +89,20 @@ class BaseThreadedTestCase(unittest.TestCase):
             self._writerThread(*args, **kwargs)
         except db.DBLockDeadlockError:
             if verbose:
-                print(currentThread().getName(), 'died from', e)
+                print(current_thread().get_name(), 'died from', e)
         else:
             if verbose:
-                print(currentThread().getName(), "finished.")
+                print(current_thread().get_name(), "finished.")
 
     def readerThread(self, *args, **kwargs):
         try:
             self._readerThread(*args, **kwargs)
         except db.DBLockDeadlockError as e:
             if verbose:
-                print(currentThread().getName(), 'died from', e)
+                print(current_thread().get_name(), 'died from', e)
         else:
             if verbose:
-                print(currentThread().getName(), "finished.")
+                print(current_thread().get_name(), "finished.")
 
 
 
@@ -143,7 +143,7 @@ class ConcurrentDataStoreBase(BaseThreadedTestCase):
             t.join()
 
     def _writerThread(self, d, howMany):
-        name = currentThread().getName()
+        name = current_thread().get_name()
         start = 0
         stop = howMany
         if verbose:
@@ -172,7 +172,7 @@ class ConcurrentDataStoreBase(BaseThreadedTestCase):
 
     def _readerThread(self, d, readerNum):
         time.sleep(0.01 * readerNum)
-        name = currentThread().getName()
+        name = current_thread().get_name()
 
         for loop in range(5):
             c = d.cursor()
@@ -240,7 +240,7 @@ class SimpleThreadedBase(BaseThreadedTestCase):
             t.join()
 
     def _writerThread(self, d, howMany, writerNum):
-        name = currentThread().getName()
+        name = current_thread().get_name()
         start = howMany * writerNum
         stop = howMany * (writerNum + 1) - 1
         if verbose:
@@ -286,7 +286,7 @@ class SimpleThreadedBase(BaseThreadedTestCase):
 
     def _readerThread(self, d, readerNum):
         time.sleep(0.01 * readerNum)
-        name = currentThread().getName()
+        name = current_thread().get_name()
 
         for loop in range(5):
             c = d.cursor()
@@ -385,7 +385,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
                 time.sleep(0.05)
 
     def _writerThread(self, d, howMany, writerNum):
-        name = currentThread().getName()
+        name = current_thread().get_name()
         start = howMany * writerNum
         stop = howMany * (writerNum + 1) - 1
         if verbose:
@@ -427,7 +427,7 @@ class ThreadedTransactionsBase(BaseThreadedTestCase):
 
     def _readerThread(self, d, readerNum):
         time.sleep(0.01 * readerNum + 0.05)
-        name = currentThread().getName()
+        name = current_thread().get_name()
 
         for loop in range(5):
             finished = False
index e555ffb301929c73d6a1e59f709bd816c411d1e6..a749353aec063d5c44f1ee465e2573472ce2884e 100644 (file)
@@ -106,7 +106,7 @@ class RPCServer(socketserver.TCPServer):
             erf = sys.__stderr__
             print('\n' + '-'*40, file=erf)
             print('Unhandled server exception!', file=erf)
-            print('Thread: %s' % threading.currentThread().getName(), file=erf)
+            print('Thread: %s' % threading.current_thread().get_name(), file=erf)
             print('Client Address: ', client_address, file=erf)
             print('Request: ', repr(request), file=erf)
             traceback.print_exc(file=erf)
@@ -126,7 +126,7 @@ class SocketIO(object):
     nextseq = 0
 
     def __init__(self, sock, objtable=None, debugging=None):
-        self.sockthread = threading.currentThread()
+        self.sockthread = threading.current_thread()
         if debugging is not None:
             self.debugging = debugging
         self.sock = sock
@@ -149,7 +149,7 @@ class SocketIO(object):
     def debug(self, *args):
         if not self.debugging:
             return
-        s = self.location + " " + str(threading.currentThread().getName())
+        s = self.location + " " + str(threading.current_thread().getName())
         for a in args:
             s = s + " " + str(a)
         print(s, file=sys.__stderr__)
@@ -218,7 +218,7 @@ class SocketIO(object):
     def asynccall(self, oid, methodname, args, kwargs):
         request = ("CALL", (oid, methodname, args, kwargs))
         seq = self.newseq()
-        if threading.currentThread() != self.sockthread:
+        if threading.current_thread() != self.sockthread:
             cvar = threading.Condition()
             self.cvars[seq] = cvar
         self.debug(("asynccall:%d:" % seq), oid, methodname, args, kwargs)
@@ -228,7 +228,7 @@ class SocketIO(object):
     def asyncqueue(self, oid, methodname, args, kwargs):
         request = ("QUEUE", (oid, methodname, args, kwargs))
         seq = self.newseq()
-        if threading.currentThread() != self.sockthread:
+        if threading.current_thread() != self.sockthread:
             cvar = threading.Condition()
             self.cvars[seq] = cvar
         self.debug(("asyncqueue:%d:" % seq), oid, methodname, args, kwargs)
@@ -294,7 +294,7 @@ class SocketIO(object):
 
     def _getresponse(self, myseq, wait):
         self.debug("_getresponse:myseq:", myseq)
-        if threading.currentThread() is self.sockthread:
+        if threading.current_thread() is self.sockthread:
             # this thread does all reading of requests or responses
             while 1:
                 response = self.pollresponse(myseq, wait)
index 7a662c97d5418b4f6bbecf11bbde6a9590dd2849..e2e9f69960feb31f6c8e023ec045bd9072326adc 100644 (file)
@@ -73,7 +73,7 @@ def main(del_exitfunc=False):
     sockthread = threading.Thread(target=manage_socket,
                                   name='SockThread',
                                   args=((LOCALHOST, port),))
-    sockthread.setDaemon(True)
+    sockthread.set_daemon(True)
     sockthread.start()
     while 1:
         try:
@@ -227,7 +227,7 @@ class MyRPCServer(rpc.RPCServer):
             erf = sys.__stderr__
             print('\n' + '-'*40, file=erf)
             print('Unhandled server exception!', file=erf)
-            print('Thread: %s' % threading.currentThread().getName(), file=erf)
+            print('Thread: %s' % threading.current_thread().get_name(), file=erf)
             print('Client Address: ', client_address, file=erf)
             print('Request: ', repr(request), file=erf)
             traceback.print_exc(file=erf)
index 2a9ec8aceddda6dc26712ec15017d63dcb4bc50e..9409e554240d11ce41c513c2022e65307415fe1e 100644 (file)
@@ -566,7 +566,7 @@ class ThreadingMixIn:
         t = threading.Thread(target = self.process_request_thread,
                              args = (request, client_address))
         if self.daemon_threads:
-            t.setDaemon (1)
+            t.set_daemon(True)
         t.start()
 
 
index d93b3824fafc3bfd28d85a781e9533d7ac7ece35..73834673846b1b8171c591f29286b3d1df35ccaf 100644 (file)
@@ -63,7 +63,7 @@ class ThreadedTempFileTest(unittest.TestCase):
             t.join()
             ok += t.ok_count
             if t.error_count:
-                errors.append(str(t.getName()) + str(t.errors.getvalue()))
+                errors.append(str(t.get_name()) + str(t.errors.getvalue()))
 
         threading_cleanup(*thread_info)
 
index 934eeaef34d6d8f2891b1da1b5c7eebccf77b190..cfa9a106a6afef2d0b8d55b60e7691e73572d513 100644 (file)
@@ -856,7 +856,7 @@ def _test():
     P = []
     for i in range(NP):
         t = ProducerThread(Q, NI)
-        t.setName("Producer-%d" % (i+1))
+        t.set_name("Producer-%d" % (i+1))
         P.append(t)
     C = ConsumerThread(Q, NI*NP)
     for t in P: