[Python-checkins] r64128 - in python/trunk: Doc/library/threading.rst Lib/threading.py Misc/NEWS (original) (raw)
Guido van Rossum guido at python.org
Wed Jun 11 19:56:34 CEST 2008
- Previous message: [Python-checkins] r64128 - in python/trunk: Doc/library/threading.rst Lib/threading.py Misc/NEWS
- Next message: [Python-checkins] r64128 - in python/trunk: Doc/library/threading.rst Lib/threading.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Shouldn't the old APIs be added back to the all variable?
On Wed, Jun 11, 2008 at 10:50 AM, benjamin.peterson <python-checkins at python.org> wrote:
Author: benjamin.peterson Date: Wed Jun 11 19:50:00 2008 New Revision: 64128
Log: add aliases to threading module
Modified: python/trunk/Doc/library/threading.rst python/trunk/Lib/threading.py python/trunk/Misc/NEWS Modified: python/trunk/Doc/library/threading.rst ============================================================================== --- python/trunk/Doc/library/threading.rst (original) +++ python/trunk/Doc/library/threading.rst Wed Jun 11 19:50:00 2008 @@ -13,10 +13,16 @@ The :mod:
dummythreading
module is provided for situations where :mod:threading
cannot be used because :mod:thread
is missing. +.. note:: + + In 3.x, names in camelCase have been renamed to their underscored + equivelents. Both names are availble in 2.6. + This module defines the following functions and objects: .. function:: activecount() + activeCount() Return the number of :class:Thread
objects currently alive. The returned count is equal to the length of the list returned by :func:enumerate
. @@ -31,6 +37,7 @@ .. function:: currentthread() + currentThread() Return the current :class:Thread
object, corresponding to the caller's thread of control. If the caller's thread of control was not created through the @@ -396,6 +403,7 @@ .. method:: Condition.notifyall() + Condition.notifyAll() Wake up all threads waiting on this condition. This method acts like :meth:notify
, but wakes up all waiting threads instead of one. If the calling @@ -498,7 +506,8 @@ The internal flag is initially false. -.. method:: Event.isSet() +.. method:: Event.isset() + Event.isSet() Return true if and only if the internal flag is true. @@ -638,11 +647,13 @@ .. method:: Thread.getname() + Thread.getName() Return the thread's name. -.. method:: Thread.setsame(name) +.. method:: Thread.setname(name) + Thread.setName(name) Set the thread's name. @@ -651,7 +662,7 @@ constructor. -.. method:: Thread.getddent() +.. method:: Thread.getident() Return the 'thread identifier' of this thread or None if the thread has not been started. This is a nonzero integer. See the :func:thread.getident()
@@ -663,6 +674,7 @@ .. method:: Thread.isalive() + Thread.isAlive() Return whether the thread is alive. @@ -672,11 +684,13 @@ .. method:: Thread.isdaemon() + Thread.isDaemon() Return the thread's daemon flag. .. method:: Thread.setdaemon(daemonic) + Thread.setDaemon(daemonic) Set the thread's daemon flag to the Boolean value daemonic. This must be called before :meth:start
is called, otherwise :exc:RuntimeError
is raised. Modified: python/trunk/Lib/threading.py ============================================================================== --- python/trunk/Lib/threading.py (original) +++ python/trunk/Lib/threading.py Wed Jun 11 19:50:00 2008 @@ -9,6 +9,8 @@ raise import warnings + +from functools import wraps from time import time as time, sleep as sleep from traceback import formatexc as formatexc from collections import deque @@ -31,6 +33,18 @@ module='threading', message='sys.excclear') +def oldapi(callable, oldname): + if not sys.py3kwarning: + return callable + @wraps(callable) + def old(*args, **kwargs): + warnings.warnpy3k("In 3.x, {0} is renamed to {1}." + .format(oldname, callable.name), + stacklevel=3) + return callable(*args, **kwargs) + old.name = oldname + return old + # Debug support (adapted from ihooks.py). # All the major classes here derive from Verbose. We force that to # be a new-style class so that all the major classes here are new-style. @@ -274,6 +288,8 @@ def notifyall(self): _self.notify(len(self.waiters)) + notifyAll = oldapi(notifyall, "notifyAll") + def Semaphore(*args, **kwargs): return Semaphore(*args, **kwargs) @@ -353,6 +369,8 @@ def isset(self): _return self.flag + isSet = oldapi(isset, "isSet") + def set(self): _self.cond.acquire() try: @@ -635,10 +653,14 @@ _assert self.initialized, "Thread.init() not called" _return self.name + getName = oldapi(getname, "getName") + def setname(self, name): _assert self.initialized, "Thread.init() not called" _self.name = str(name) + setName = oldapi(setname, "setName") + def getident(self): _assert self.initialized, "Thread.init() not called" _return self.ident @@ -647,10 +669,14 @@ _assert self.initialized, "Thread.init() not called" _return self._started.isset() and not self.stopped + isAlive = oldapi(isalive, "isAlive") + def isdaemon(self): _assert self.initialized, "Thread.init() not called" _return self.daemonic + isDaemon = oldapi(isdaemon, "isDaemon") + def setdaemon(self, daemonic): _if not self.initialized: raise RuntimeError("Thread.init() not called") @@ -658,6 +684,8 @@ raise RuntimeError("cannot set daemon status of active thread"); _self.daemonic = daemonic + setDaemon = oldapi(setdaemon, "setDaemon") + # The timer class was contributed by Itamar Shtull-Trauring def Timer(*args, **kwargs): @@ -763,12 +791,16 @@ ##print "currentthread(): no current thread for", getident() return DummyThread() +currentThread = oldapi(currentthread, "currentThread") + def activecount(): activelimbolock.acquire() count = len(active) + len(limbo) activelimbolock.release() return count +activeCount = oldapi(activecount, "activeCount") + def enumerate(): activelimbolock.acquire() active = active.values() + limbo.values() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Jun 11 19:50:00 2008 @@ -291,6 +291,7 @@ - The bundled OSX-specific copy of libbffi is now in sync with the version shipped with PyObjC 2.0 and includes support for x8664 and ppc64 platforms. +- The threading module gained alias for names that are removed in 3.x. Build -----
Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-checkins] r64128 - in python/trunk: Doc/library/threading.rst Lib/threading.py Misc/NEWS
- Next message: [Python-checkins] r64128 - in python/trunk: Doc/library/threading.rst Lib/threading.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]