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
f4395602
Kaydet (Commit)
f4395602
authored
Haz 11, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add aliases to threading module
üst
0fbcf694
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
threading.rst
Doc/library/threading.rst
+17
-3
threading.py
Lib/threading.py
+32
-0
NEWS
Misc/NEWS
+1
-0
No files found.
Doc/library/threading.rst
Dosyayı görüntüle @
f4395602
...
...
@@ -13,10 +13,16 @@ See also the :mod:`mutex` and :mod:`Queue` modules.
The :mod:`dummy_threading` 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:: active_count()
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 @@ This module defines the following functions and objects:
.. function:: current_thread()
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 @@ needs to wake up one consumer thread.
.. method:: Condition.notify_all()
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 @@ An event object manages an internal flag that can be set to true with the
The internal flag is initially false.
.. method:: Event.isSet()
.. method:: Event.is_set()
Event.isSet()
Return true if and only if the internal flag is true.
...
...
@@ -638,11 +647,13 @@ impossible to detect the termination of alien threads.
.. method:: Thread.get_name()
Thread.getName()
Return the thread's name.
.. method:: Thread.set_same(name)
.. method:: Thread.set_name(name)
Thread.setName(name)
Set the thread's name.
...
...
@@ -651,7 +662,7 @@ impossible to detect the termination of alien threads.
constructor.
.. method:: Thread.get_
d
dent()
.. method:: Thread.get_
i
dent()
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.get_ident()`
...
...
@@ -663,6 +674,7 @@ impossible to detect the termination of alien threads.
.. method:: Thread.is_alive()
Thread.isAlive()
Return whether the thread is alive.
...
...
@@ -672,11 +684,13 @@ impossible to detect the termination of alien threads.
.. method:: Thread.is_daemon()
Thread.isDaemon()
Return the thread's daemon flag.
.. method:: Thread.set_daemon(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.
...
...
Lib/threading.py
Dosyayı görüntüle @
f4395602
...
...
@@ -9,6 +9,8 @@ except ImportError:
raise
import
warnings
from
functools
import
wraps
from
time
import
time
as
_time
,
sleep
as
_sleep
from
traceback
import
format_exc
as
_format_exc
from
collections
import
deque
...
...
@@ -31,6 +33,18 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
module
=
'threading'
,
message
=
'sys.exc_clear'
)
def
_old_api
(
callable
,
old_name
):
if
not
_sys
.
py3kwarning
:
return
callable
@wraps
(
callable
)
def
old
(
*
args
,
**
kwargs
):
warnings
.
warnpy3k
(
"In 3.x, {0} is renamed to {1}."
.
format
(
old_name
,
callable
.
__name__
),
stacklevel
=
3
)
return
callable
(
*
args
,
**
kwargs
)
old
.
__name__
=
old_name
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 @@ class _Condition(_Verbose):
def
notify_all
(
self
):
self
.
notify
(
len
(
self
.
__waiters
))
notifyAll
=
_old_api
(
notify_all
,
"notifyAll"
)
def
Semaphore
(
*
args
,
**
kwargs
):
return
_Semaphore
(
*
args
,
**
kwargs
)
...
...
@@ -353,6 +369,8 @@ class _Event(_Verbose):
def
is_set
(
self
):
return
self
.
__flag
isSet
=
_old_api
(
is_set
,
"isSet"
)
def
set
(
self
):
self
.
__cond
.
acquire
()
try
:
...
...
@@ -635,10 +653,14 @@ class Thread(_Verbose):
assert
self
.
__initialized
,
"Thread.__init__() not called"
return
self
.
__name
getName
=
_old_api
(
get_name
,
"getName"
)
def
set_name
(
self
,
name
):
assert
self
.
__initialized
,
"Thread.__init__() not called"
self
.
__name
=
str
(
name
)
setName
=
_old_api
(
set_name
,
"setName"
)
def
get_ident
(
self
):
assert
self
.
__initialized
,
"Thread.__init__() not called"
return
self
.
__ident
...
...
@@ -647,10 +669,14 @@ class Thread(_Verbose):
assert
self
.
__initialized
,
"Thread.__init__() not called"
return
self
.
__started
.
is_set
()
and
not
self
.
__stopped
isAlive
=
_old_api
(
is_alive
,
"isAlive"
)
def
is_daemon
(
self
):
assert
self
.
__initialized
,
"Thread.__init__() not called"
return
self
.
__daemonic
isDaemon
=
_old_api
(
is_daemon
,
"isDaemon"
)
def
set_daemon
(
self
,
daemonic
):
if
not
self
.
__initialized
:
raise
RuntimeError
(
"Thread.__init__() not called"
)
...
...
@@ -658,6 +684,8 @@ class Thread(_Verbose):
raise
RuntimeError
(
"cannot set daemon status of active thread"
);
self
.
__daemonic
=
daemonic
setDaemon
=
_old_api
(
set_daemon
,
"setDaemon"
)
# The timer class was contributed by Itamar Shtull-Trauring
def
Timer
(
*
args
,
**
kwargs
):
...
...
@@ -763,12 +791,16 @@ def current_thread():
##print "current_thread(): no current thread for", _get_ident()
return
_DummyThread
()
currentThread
=
_old_api
(
current_thread
,
"currentThread"
)
def
active_count
():
_active_limbo_lock
.
acquire
()
count
=
len
(
_active
)
+
len
(
_limbo
)
_active_limbo_lock
.
release
()
return
count
activeCount
=
_old_api
(
active_count
,
"activeCount"
)
def
enumerate
():
_active_limbo_lock
.
acquire
()
active
=
_active
.
values
()
+
_limbo
.
values
()
...
...
Misc/NEWS
Dosyayı görüntüle @
f4395602
...
...
@@ -291,6 +291,7 @@ Library
- The bundled OSX-specific copy of libbffi is now in sync with the version
shipped with PyObjC 2.0 and includes support for x86_64 and ppc64 platforms.
- The threading module gained alias for names that are removed in 3.x.
Build
-----
...
...
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