Skip to content

Commit f992640

Browse files
committed
Fix last traces of old threading API.
1 parent 7634ff5 commit f992640

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

Doc/includes/mp_distributing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def set_contents(self, contents):
243243
try:
244244
self.queue.clear()
245245
self.queue.extend(contents)
246-
self.not_empty.notifyAll()
246+
self.not_empty.notify_all()
247247
finally:
248248
self.not_empty.release()
249249

Doc/library/queue.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Example of how to wait for enqueued tasks to be completed::
147147
q = Queue()
148148
for i in range(num_worker_threads):
149149
t = Thread(target=worker)
150-
t.setDaemon(True)
150+
t.set_daemon(True)
151151
t.start()
152152

153153
for item in source():

Doc/library/socketserver.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ An example for the :class:`ThreadingMixIn` class::
480480

481481
def handle(self):
482482
data = self.request.recv(1024)
483-
cur_thread = threading.currentThread()
484-
response = "%s: %s" % (cur_thread.getName(), data)
483+
cur_thread = threading.current_thread()
484+
response = "%s: %s" % (cur_thread.get_name(), data)
485485
self.request.send(response)
486486

487487
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
@@ -506,9 +506,9 @@ An example for the :class:`ThreadingMixIn` class::
506506
# more thread for each request
507507
server_thread = threading.Thread(target=server.serve_forever)
508508
# Exit the server thread when the main thread terminates
509-
server_thread.setDaemon(True)
509+
server_thread.set_daemon(True)
510510
server_thread.start()
511-
print "Server loop running in thread:", t.getName()
511+
print "Server loop running in thread:", t.get_name()
512512

513513
client(ip, port, "Hello World 1")
514514
client(ip, port, "Hello World 2")

Doc/library/threading.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,29 +283,29 @@ several condition variables must share the same lock.)
283283

284284
A condition variable has :meth:`acquire` and :meth:`release` methods that call
285285
the corresponding methods of the associated lock. It also has a :meth:`wait`
286-
method, and :meth:`notify` and :meth:`notifyAll` methods. These three must only
286+
method, and :meth:`notify` and :meth:`notify_all` methods. These three must only
287287
be called when the calling thread has acquired the lock, otherwise a
288288
:exc:`RuntimeError` is raised.
289289

290290
The :meth:`wait` method releases the lock, and then blocks until it is awakened
291-
by a :meth:`notify` or :meth:`notifyAll` call for the same condition variable in
291+
by a :meth:`notify` or :meth:`notify_all` call for the same condition variable in
292292
another thread. Once awakened, it re-acquires the lock and returns. It is also
293293
possible to specify a timeout.
294294

295295
The :meth:`notify` method wakes up one of the threads waiting for the condition
296-
variable, if any are waiting. The :meth:`notifyAll` method wakes up all threads
296+
variable, if any are waiting. The :meth:`notify_all` method wakes up all threads
297297
waiting for the condition variable.
298298

299-
Note: the :meth:`notify` and :meth:`notifyAll` methods don't release the lock;
299+
Note: the :meth:`notify` and :meth:`notify_all` methods don't release the lock;
300300
this means that the thread or threads awakened will not return from their
301301
:meth:`wait` call immediately, but only when the thread that called
302-
:meth:`notify` or :meth:`notifyAll` finally relinquishes ownership of the lock.
302+
:meth:`notify` or :meth:`notify_all` finally relinquishes ownership of the lock.
303303

304304
Tip: the typical programming style using condition variables uses the lock to
305305
synchronize access to some shared state; threads that are interested in a
306306
particular change of state call :meth:`wait` repeatedly until they see the
307307
desired state, while threads that modify the state call :meth:`notify` or
308-
:meth:`notifyAll` when they change the state in such a way that it could
308+
:meth:`notify_all` when they change the state in such a way that it could
309309
possibly be a desired state for one of the waiters. For example, the following
310310
code is a generic producer-consumer situation with unlimited buffer capacity::
311311

@@ -322,7 +322,7 @@ code is a generic producer-consumer situation with unlimited buffer capacity::
322322
cv.notify()
323323
cv.release()
324324

325-
To choose between :meth:`notify` and :meth:`notifyAll`, consider whether one
325+
To choose between :meth:`notify` and :meth:`notify_all`, consider whether one
326326
state change can be interesting for only one or several waiting threads. E.g.
327327
in a typical producer-consumer situation, adding one item to the buffer only
328328
needs to wake up one consumer thread.
@@ -353,7 +353,7 @@ needs to wake up one consumer thread.
353353
acquired the lock when this method is called, a :exc:`RuntimeError` is raised.
354354

355355
This method releases the underlying lock, and then blocks until it is awakened
356-
by a :meth:`notify` or :meth:`notifyAll` call for the same condition variable in
356+
by a :meth:`notify` or :meth:`notify_all` call for the same condition variable in
357357
another thread, or until the optional timeout occurs. Once awakened or timed
358358
out, it re-acquires the lock and returns.
359359

@@ -490,7 +490,7 @@ An event object manages an internal flag that can be set to true with the
490490
The internal flag is initially false.
491491

492492

493-
.. method:: Event.isSet()
493+
.. method:: Event.is_set()
494494

495495
Return true if and only if the internal flag is true.
496496

@@ -537,7 +537,7 @@ separate thread of control.
537537

538538
Once the thread's activity is started, the thread is considered 'alive'. It
539539
stops being alive when its :meth:`run` method terminates -- either normally, or
540-
by raising an unhandled exception. The :meth:`isAlive` method tests whether the
540+
by raising an unhandled exception. The :meth:`is_alive` method tests whether the
541541
thread is alive.
542542

543543
Other threads can call a thread's :meth:`join` method. This blocks the calling
@@ -614,7 +614,7 @@ impossible to detect the termination of alien threads.
614614

615615
When the *timeout* argument is present and not ``None``, it should be a floating
616616
point number specifying a timeout for the operation in seconds (or fractions
617-
thereof). As :meth:`join` always returns ``None``, you must call :meth:`isAlive`
617+
thereof). As :meth:`join` always returns ``None``, you must call :meth:`is_alive`
618618
after :meth:`join` to decide whether a timeout happened -- if the thread is
619619
still alive, the :meth:`join` call timed out.
620620

Lib/decimal.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class Underflow(Inexact, Rounded, Subnormal):
383383

384384
# The getcontext() and setcontext() function manage access to a thread-local
385385
# current context. Py2.4 offers direct support for thread locals. If that
386-
# is not available, use threading.currentThread() which is slower but will
386+
# is not available, use threading.current_thread() which is slower but will
387387
# work for older Pythons. If threads are not part of the build, create a
388388
# mock threading object with threading.local() returning the module namespace.
389389

@@ -405,15 +405,15 @@ def local(self, sys=sys):
405405

406406
# To fix reloading, force it to create a new context
407407
# Old contexts have different exceptions in their dicts, making problems.
408-
if hasattr(threading.currentThread(), '__decimal_context__'):
409-
del threading.currentThread().__decimal_context__
408+
if hasattr(threading.current_thread(), '__decimal_context__'):
409+
del threading.current_thread().__decimal_context__
410410

411411
def setcontext(context):
412412
"""Set this thread's context to context."""
413413
if context in (DefaultContext, BasicContext, ExtendedContext):
414414
context = context.copy()
415415
context.clear_flags()
416-
threading.currentThread().__decimal_context__ = context
416+
threading.current_thread().__decimal_context__ = context
417417

418418
def getcontext():
419419
"""Returns this thread's context.
@@ -423,10 +423,10 @@ def getcontext():
423423
New contexts are copies of DefaultContext.
424424
"""
425425
try:
426-
return threading.currentThread().__decimal_context__
426+
return threading.current_thread().__decimal_context__
427427
except AttributeError:
428428
context = Context()
429-
threading.currentThread().__decimal_context__ = context
429+
threading.current_thread().__decimal_context__ = context
430430
return context
431431

432432
else:

Lib/idlelib/rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def exithook(self):
149149
def debug(self, *args):
150150
if not self.debugging:
151151
return
152-
s = self.location + " " + str(threading.current_thread().getName())
152+
s = self.location + " " + str(threading.current_thread().get_name())
153153
for a in args:
154154
s = s + " " + str(a)
155155
print(s, file=sys.__stderr__)

Misc/NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Library
175175

176176
- The test.test_support module has been renamed to test.support.
177177

178-
- The threading module API's were renamed to by PEP 8 complaint.
178+
- The threading module API was renamed to be PEP 8 complaint.
179179

180180
Tools/Demos
181181
-----------

0 commit comments

Comments
 (0)