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
f0923f52
Kaydet (Commit)
f0923f52
authored
Agu 18, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add full deprecation warnings for old threading APIs
üst
2faaeceb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
test_threading.py
Lib/test/test_threading.py
+38
-1
threading.py
Lib/threading.py
+28
-0
No files found.
Lib/test/test_threading.py
Dosyayı görüntüle @
f0923f52
# Very rudimentary test of threading module
import
test.support
from
test.support
import
verbose
from
test.support
import
verbose
,
catch_warning
import
random
import
re
import
sys
...
...
@@ -323,6 +323,43 @@ class ThreadTests(unittest.TestCase):
msg
=
(
'
%
d references still around'
%
sys
.
getrefcount
(
weak_raising_cyclic_object
())))
def
test_pep8ified_threading
(
self
):
import
threading
def
check
(
_
,
w
,
msg
):
self
.
assertEqual
(
str
(
w
.
message
),
msg
)
t
=
threading
.
Thread
()
with
catch_warning
()
as
w
:
msg
=
"isDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
check
(
t
.
isDaemon
(),
w
,
msg
)
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
):
...
...
Lib/threading.py
Dosyayı görüntüle @
f0923f52
...
...
@@ -2,6 +2,7 @@
import
sys
as
_sys
import
_thread
import
warnings
from
time
import
time
as
_time
,
sleep
as
_sleep
from
traceback
import
format_exc
as
_format_exc
...
...
@@ -340,6 +341,11 @@ class _Event(_Verbose):
def
is_set
(
self
):
return
self
.
_flag
def
isSet
(
self
):
warnings
.
warn
(
"isSet() is deprecated in favor of is_set()"
,
DeprecationWarning
)
return
self
.
is_set
()
def
set
(
self
):
self
.
_cond
.
acquire
()
try
:
...
...
@@ -640,6 +646,11 @@ class Thread(_Verbose):
assert
self
.
_initialized
,
"Thread.__init__() not called"
return
self
.
_started
.
is_set
()
and
not
self
.
_stopped
def
isAlive
(
self
):
warnings
.
warn
(
"isAlive() is deprecated in favor of is_alive()"
,
DeprecationWarning
)
return
self
.
is_alive
()
@property
def
daemon
(
self
):
assert
self
.
_initialized
,
"Thread.__init__() not called"
...
...
@@ -654,15 +665,23 @@ class Thread(_Verbose):
self
.
_daemonic
=
daemonic
def
isDaemon
(
self
):
warnings
.
warn
(
"isDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
,
DeprecationWarning
)
return
self
.
daemon
def
setDaemon
(
self
,
daemonic
):
warnings
.
warn
(
"setDaemon() is deprecated in favor of the "
\
"Thread.daemon property"
,
DeprecationWarning
)
self
.
daemon
=
daemonic
def
getName
(
self
):
warnings
.
warn
(
"getName() is deprecated in favor of the "
\
"Thread.name property"
,
DeprecationWarning
)
return
self
.
name
def
setName
(
self
,
name
):
warnings
.
warn
(
"setName() is deprecated in favor of the "
\
"Thread.name property"
,
DeprecationWarning
)
self
.
name
=
name
# The timer class was contributed by Itamar Shtull-Trauring
...
...
@@ -771,12 +790,21 @@ def current_thread():
##print "current_thread(): no current thread for", _get_ident()
return
_DummyThread
()
def
currentThread
():
warnings
.
warn
(
"currentThread() is deprecated in favor of current_thread()"
,
DeprecationWarning
)
def
active_count
():
_active_limbo_lock
.
acquire
()
count
=
len
(
_active
)
+
len
(
_limbo
)
_active_limbo_lock
.
release
()
return
count
def
activeCount
():
warnings
.
warn
(
"activeCount() is deprecated in favor of active_count()"
,
DeprecationWarning
)
return
active_count
()
def
enumerate
():
_active_limbo_lock
.
acquire
()
active
=
list
(
_active
.
values
())
+
list
(
_limbo
.
values
())
...
...
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