Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b3085c9e
Kaydet (Commit)
b3085c9e
authored
Eyl 01, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
remove the deprecation warnings for the old threading API; update the docs
Reviewer: Benjamin Peterson
üst
f82b856b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
66 deletions
+33
-66
threading.rst
Doc/library/threading.rst
+3
-5
test_threading.py
Lib/test/test_threading.py
+11
-37
threading.py
Lib/threading.py
+17
-24
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/threading.rst
Dosyayı görüntüle @
b3085c9e
...
@@ -14,11 +14,9 @@ The :mod:`dummy_threading` module is provided for situations where
...
@@ -14,11 +14,9 @@ The :mod:`dummy_threading` module is provided for situations where
.. note::
.. note::
Some ``camelCase`` names have been converted to their underscored
While they are not listed below, the ``camelCase`` names used for some
equivalents. Others have been replaced by properties. Using the old methods
methods and functions in this module in the Python 2.x series are still
in 2.6 will trigger a :exc:`DeprecationWarning` when Python is run with the
supported by this module.
:option:`-3` flag and a full :exc:`DeprecationWarning` in 3.0. The old names
will be removed early in the 3.x series.
This module defines the following functions and objects:
This module defines the following functions and objects:
...
...
Lib/test/test_threading.py
Dosyayı görüntüle @
b3085c9e
...
@@ -323,44 +323,18 @@ class ThreadTests(unittest.TestCase):
...
@@ -323,44 +323,18 @@ class ThreadTests(unittest.TestCase):
msg
=
(
'
%
d references still around'
%
msg
=
(
'
%
d references still around'
%
sys
.
getrefcount
(
weak_raising_cyclic_object
())))
sys
.
getrefcount
(
weak_raising_cyclic_object
())))
def
test_pep8ified_threading
(
self
):
def
test_old_threading_api
(
self
):
def
check
(
_
,
w
,
msg
):
# Just a quick sanity check to make sure the old method names are
self
.
assertEqual
(
str
(
w
.
message
),
msg
)
# still present
t
=
threading
.
Thread
()
t
=
threading
.
Thread
()
with
catch_warning
()
as
w
:
t
.
isDaemon
()
try
:
t
.
setDaemon
(
True
)
del
threading
.
__warningregistry__
t
.
getName
()
except
AttributeError
:
t
.
setName
(
"name"
)
pass
t
.
isAlive
()
msg
=
"isDaemon() is deprecated in favor of the "
\
e
=
threading
.
Event
()
"Thread.daemon property"
e
.
isSet
()
check
(
t
.
isDaemon
(),
w
,
msg
)
threading
.
activeCount
()
w
.
reset
()
msg
=
"setDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
check
(
t
.
setDaemon
(
True
),
w
,
msg
)
w
.
reset
()
msg
=
"getName() is deprecated in favor of the "
\
"Thread.name property"
check
(
t
.
getName
(),
w
,
msg
)
w
.
reset
()
msg
=
"setName() is deprecated in favor of the "
\
"Thread.name property"
check
(
t
.
setName
(
"name"
),
w
,
msg
)
w
.
reset
()
msg
=
"isAlive() is deprecated in favor of is_alive()"
check
(
t
.
isAlive
(),
w
,
msg
)
w
.
reset
()
e
=
threading
.
Event
()
msg
=
"isSet() is deprecated in favor of is_set()"
check
(
e
.
isSet
(),
w
,
msg
)
w
.
reset
()
msg
=
"currentThread() is deprecated in favor of current_thread()"
check
(
threading
.
currentThread
(),
w
,
msg
)
w
.
reset
()
msg
=
"activeCount() is deprecated in favor of active_count()"
check
(
threading
.
activeCount
(),
w
,
msg
)
class
ThreadJoinOnShutdown
(
unittest
.
TestCase
):
class
ThreadJoinOnShutdown
(
unittest
.
TestCase
):
...
...
Lib/threading.py
Dosyayı görüntüle @
b3085c9e
...
@@ -2,12 +2,22 @@
...
@@ -2,12 +2,22 @@
import
sys
as
_sys
import
sys
as
_sys
import
_thread
import
_thread
import
warnings
from
time
import
time
as
_time
,
sleep
as
_sleep
from
time
import
time
as
_time
,
sleep
as
_sleep
from
traceback
import
format_exc
as
_format_exc
from
traceback
import
format_exc
as
_format_exc
from
collections
import
deque
from
collections
import
deque
# Note regarding PEP 8 compliant names
# This threading model was originally inspired by Java, and inherited
# the convention of camelCase function and method names from that
# language. Those originaly names are not in any imminent danger of
# being deprecated (even for Py3k),so this module provides them as an
# alias for the PEP 8 compliant names
# Note that using the new PEP 8 compliant names facilitates substitution
# with the multiprocessing module, which doesn't provide the old
# Java inspired names.
# Rename some stuff so "from threading import *" is safe
# Rename some stuff so "from threading import *" is safe
__all__
=
[
'active_count'
,
'Condition'
,
'current_thread'
,
'enumerate'
,
'Event'
,
__all__
=
[
'active_count'
,
'Condition'
,
'current_thread'
,
'enumerate'
,
'Event'
,
'Lock'
,
'RLock'
,
'Semaphore'
,
'BoundedSemaphore'
,
'Thread'
,
'Lock'
,
'RLock'
,
'Semaphore'
,
'BoundedSemaphore'
,
'Thread'
,
...
@@ -262,6 +272,8 @@ class _Condition(_Verbose):
...
@@ -262,6 +272,8 @@ class _Condition(_Verbose):
def
notify_all
(
self
):
def
notify_all
(
self
):
self
.
notify
(
len
(
self
.
_waiters
))
self
.
notify
(
len
(
self
.
_waiters
))
notifyAll
=
notify_all
def
Semaphore
(
*
args
,
**
kwargs
):
def
Semaphore
(
*
args
,
**
kwargs
):
return
_Semaphore
(
*
args
,
**
kwargs
)
return
_Semaphore
(
*
args
,
**
kwargs
)
...
@@ -341,10 +353,7 @@ class _Event(_Verbose):
...
@@ -341,10 +353,7 @@ class _Event(_Verbose):
def
is_set
(
self
):
def
is_set
(
self
):
return
self
.
_flag
return
self
.
_flag
def
isSet
(
self
):
isSet
=
is_set
warnings
.
warn
(
"isSet() is deprecated in favor of is_set()"
,
DeprecationWarning
)
return
self
.
is_set
()
def
set
(
self
):
def
set
(
self
):
self
.
_cond
.
acquire
()
self
.
_cond
.
acquire
()
...
@@ -646,10 +655,7 @@ class Thread(_Verbose):
...
@@ -646,10 +655,7 @@ class Thread(_Verbose):
assert
self
.
_initialized
,
"Thread.__init__() not called"
assert
self
.
_initialized
,
"Thread.__init__() not called"
return
self
.
_started
.
is_set
()
and
not
self
.
_stopped
return
self
.
_started
.
is_set
()
and
not
self
.
_stopped
def
isAlive
(
self
):
isAlive
=
is_alive
warnings
.
warn
(
"isAlive() is deprecated in favor of is_alive()"
,
DeprecationWarning
)
return
self
.
is_alive
()
@property
@property
def
daemon
(
self
):
def
daemon
(
self
):
...
@@ -665,23 +671,15 @@ class Thread(_Verbose):
...
@@ -665,23 +671,15 @@ class Thread(_Verbose):
self
.
_daemonic
=
daemonic
self
.
_daemonic
=
daemonic
def
isDaemon
(
self
):
def
isDaemon
(
self
):
warnings
.
warn
(
"isDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
,
DeprecationWarning
)
return
self
.
daemon
return
self
.
daemon
def
setDaemon
(
self
,
daemonic
):
def
setDaemon
(
self
,
daemonic
):
warnings
.
warn
(
"setDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
,
DeprecationWarning
)
self
.
daemon
=
daemonic
self
.
daemon
=
daemonic
def
getName
(
self
):
def
getName
(
self
):
warnings
.
warn
(
"getName() is deprecated in favor of the "
\
"Thread.name property"
,
DeprecationWarning
)
return
self
.
name
return
self
.
name
def
setName
(
self
,
name
):
def
setName
(
self
,
name
):
warnings
.
warn
(
"setName() is deprecated in favor of the "
\
"Thread.name property"
,
DeprecationWarning
)
self
.
name
=
name
self
.
name
=
name
# The timer class was contributed by Itamar Shtull-Trauring
# The timer class was contributed by Itamar Shtull-Trauring
...
@@ -790,9 +788,7 @@ def current_thread():
...
@@ -790,9 +788,7 @@ def current_thread():
##print "current_thread(): no current thread for", _get_ident()
##print "current_thread(): no current thread for", _get_ident()
return
_DummyThread
()
return
_DummyThread
()
def
currentThread
():
currentThread
=
current_thread
warnings
.
warn
(
"currentThread() is deprecated in favor of current_thread()"
,
DeprecationWarning
)
def
active_count
():
def
active_count
():
_active_limbo_lock
.
acquire
()
_active_limbo_lock
.
acquire
()
...
@@ -800,10 +796,7 @@ def active_count():
...
@@ -800,10 +796,7 @@ def active_count():
_active_limbo_lock
.
release
()
_active_limbo_lock
.
release
()
return
count
return
count
def
activeCount
():
activeCount
=
active_count
warnings
.
warn
(
"activeCount() is deprecated in favor of active_count()"
,
DeprecationWarning
)
return
active_count
()
def
enumerate
():
def
enumerate
():
_active_limbo_lock
.
acquire
()
_active_limbo_lock
.
acquire
()
...
...
Misc/NEWS
Dosyayı görüntüle @
b3085c9e
...
@@ -60,6 +60,8 @@ C API
...
@@ -60,6 +60,8 @@ C API
Library
Library
-------
-------
- The deprecation warnings for the camelCase threading API names were removed.
Extension Modules
Extension Modules
-----------------
-----------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment