]> granicus.if.org Git - python/commitdiff
change a few uses of the threading APIs
authorBenjamin Peterson <benjamin@python.org>
Mon, 18 Aug 2008 18:01:43 +0000 (18:01 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 18 Aug 2008 18:01:43 +0000 (18:01 +0000)
Lib/logging/__init__.py
Lib/multiprocessing/managers.py
Lib/multiprocessing/queues.py
Lib/test/test_dummy_threading.py
Lib/test/test_multiprocessing.py
Lib/test/test_socketserver.py

index 9b91b9ca40813ef7848cd509382977db56d3d040..ae001db4da6b6c112f358d38bcfaec3e8d13a9e9 100644 (file)
@@ -262,7 +262,7 @@ class LogRecord:
         self.relativeCreated = (self.created - _startTime) * 1000
         if logThreads and thread:
             self.thread = thread.get_ident()
-            self.threadName = threading.current_thread().get_name()
+            self.threadName = threading.current_thread().name
         else:
             self.thread = None
             self.threadName = None
index ba5af5701f42eb07a8ec2ae0f65eb758ef4d3c56..160c1cc57d5e8d920427a6ca4a998c4458512f2e 100644 (file)
@@ -201,7 +201,7 @@ class Server(object):
         Handle requests from the proxies in a particular process/thread
         '''
         util.debug('starting server thread to service %r',
-                   threading.current_thread().get_name())
+                   threading.current_thread().name)
 
         recv = conn.recv
         send = conn.send
@@ -251,7 +251,7 @@ class Server(object):
 
             except EOFError:
                 util.debug('got EOF -- exiting thread serving %r',
-                           threading.current_thread().get_name())
+                           threading.current_thread().name)
                 sys.exit(0)
 
             except Exception:
@@ -264,7 +264,7 @@ class Server(object):
                     send(('#UNSERIALIZABLE', repr(msg)))
             except Exception, e:
                 util.info('exception in thread serving %r',
-                        threading.current_thread().get_name())
+                        threading.current_thread().name)
                 util.info(' ... message was %r', msg)
                 util.info(' ... exception was %r', e)
                 conn.close()
@@ -386,7 +386,7 @@ class Server(object):
         '''
         Spawn a new thread to serve this connection
         '''
-        threading.current_thread().set_name(name)
+        threading.current_thread().name = name
         c.send(('#RETURN', None))
         self.serve_client(c)
 
@@ -700,8 +700,8 @@ class BaseProxy(object):
     def _connect(self):
         util.debug('making connection to manager')
         name = current_process().get_name()
-        if threading.current_thread().get_name() != 'MainThread':
-            name += '|' + threading.current_thread().get_name()
+        if threading.current_thread().name != 'MainThread':
+            name += '|' + threading.current_thread().name
         conn = self._Client(self._token.address, authkey=self._authkey)
         dispatch(conn, None, 'accept_connection', (name,))
         self._tls.connection = conn
@@ -714,7 +714,7 @@ class BaseProxy(object):
             conn = self._tls.connection
         except AttributeError:
             util.debug('thread %r does not own a connection',
-                       threading.current_thread().get_name())
+                       threading.current_thread().name)
             self._connect()
             conn = self._tls.connection
 
@@ -775,7 +775,7 @@ class BaseProxy(object):
         # the process owns no more references to objects for this manager
         if not idset and hasattr(tls, 'connection'):
             util.debug('thread %r has no more proxies so closing conn',
-                       threading.current_thread().get_name())
+                       threading.current_thread().name)
             tls.connection.close()
             del tls.connection
 
index 7235a41c76731afe3ab6e86ceadb503e925fdcb9..bfb5f09e11e9485856f4f159d08fdc4594276c00 100644 (file)
@@ -155,7 +155,7 @@ class Queue(object):
                   self._wlock, self._writer.close),
             name='QueueFeederThread'
             )
-        self._thread.set_daemon(True)
+        self._thread.daemon = True
 
         debug('doing self._thread.start()')
         self._thread.start()
index ce248a2390f002b37bd58b55080ae358094d94e9..2f59d5f9811144b4451f01699bddaeffa483bb0c 100644 (file)
@@ -16,7 +16,7 @@ class DummyThreadingTestCase(unittest.TestCase):
             #delay = random.random() * 2
             delay = 0
             if test_support.verbose:
-                print 'task', self.get_name(), 'will run for', delay, 'sec'
+                print 'task', self.name, 'will run for', delay, 'sec'
             sema.acquire()
             mutex.acquire()
             running += 1
@@ -25,11 +25,11 @@ class DummyThreadingTestCase(unittest.TestCase):
             mutex.release()
             time.sleep(delay)
             if test_support.verbose:
-                print 'task', self.get_name(), 'done'
+                print 'task', self.name, 'done'
             mutex.acquire()
             running -= 1
             if test_support.verbose:
-                print self.get_name(), 'is finished.', running, 'tasks are running'
+                print self.name, 'is finished.', running, 'tasks are running'
             mutex.release()
             sema.release()
 
index 95570c259296c7ef4caaa0f2e8d0d99ec8459e02..63e34c6f7d91652a1b926810a1a2114445405016 100644 (file)
@@ -670,7 +670,7 @@ class _TestCondition(BaseTestCase):
 
             t = threading.Thread(target=self.f,
                                  args=(cond, sleeping, woken, TIMEOUT1))
-            t.set_daemon(True)
+            t.daemon = True
             t.start()
 
         # wait for them all to sleep
@@ -692,7 +692,7 @@ class _TestCondition(BaseTestCase):
             p.start()
 
             t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
-            t.set_daemon(True)
+            t.daemon = True
             t.start()
 
         # wait for them to all sleep
index f6de8fac3f99de467b0c445021365c9512eadd44..b8f664fd67f0399ce2555c89c01bdd81d1dc654b 100644 (file)
@@ -139,7 +139,7 @@ class SocketServerTest(unittest.TestCase):
             # Time between requests is short enough that we won't wake
             # up spuriously too many times.
             kwargs={'poll_interval':0.01})
-        t.set_daemon(True)  # In case this function raises.
+        t.daemon = True  # In case this function raises.
         t.start()
         if verbose: print "server running"
         for i in range(3):