mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Revert "bpo-36084: Add native thread ID to threading.Thread objects (GH-11993)" (GH-13458)
This reverts commit 4959c33d25
.
This commit is contained in:
parent
925af1d99b
commit
d12e75734d
10 changed files with 2 additions and 133 deletions
|
@ -71,10 +71,6 @@ def get_ident():
|
|||
"""
|
||||
return 1
|
||||
|
||||
def get_native_id():
|
||||
"""Dummy implementation of _thread.get_native_id()."""
|
||||
return 0
|
||||
|
||||
def allocate_lock():
|
||||
"""Dummy implementation of _thread.allocate_lock()."""
|
||||
return LockType()
|
||||
|
|
|
@ -104,10 +104,6 @@ class ThreadTests(BaseTestCase):
|
|||
self.assertRegex(repr(t), r'^<TestThread\(.*, initial\)>$')
|
||||
t.start()
|
||||
|
||||
native_ids = set(t.native_id for t in threads) | {threading.get_native_id()}
|
||||
self.assertNotIn(None, native_ids)
|
||||
self.assertEqual(len(native_ids), NUMTASKS + 1)
|
||||
|
||||
if verbose:
|
||||
print('waiting for all tasks to complete')
|
||||
for t in threads:
|
||||
|
|
|
@ -23,8 +23,8 @@ except ImportError:
|
|||
# with the multiprocessing module, which doesn't provide the old
|
||||
# Java inspired names.
|
||||
|
||||
__all__ = ['get_ident', 'get_native_id', 'active_count', 'Condition',
|
||||
'current_thread', 'enumerate', 'main_thread', 'TIMEOUT_MAX',
|
||||
__all__ = ['get_ident', 'active_count', 'Condition', 'current_thread',
|
||||
'enumerate', 'main_thread', 'TIMEOUT_MAX',
|
||||
'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
|
||||
'Barrier', 'BrokenBarrierError', 'Timer', 'ThreadError',
|
||||
'setprofile', 'settrace', 'local', 'stack_size']
|
||||
|
@ -34,7 +34,6 @@ _start_new_thread = _thread.start_new_thread
|
|||
_allocate_lock = _thread.allocate_lock
|
||||
_set_sentinel = _thread._set_sentinel
|
||||
get_ident = _thread.get_ident
|
||||
get_native_id = _thread.get_native_id
|
||||
ThreadError = _thread.error
|
||||
try:
|
||||
_CRLock = _thread.RLock
|
||||
|
@ -791,7 +790,6 @@ class Thread:
|
|||
else:
|
||||
self._daemonic = current_thread().daemon
|
||||
self._ident = None
|
||||
self._native_id = 0
|
||||
self._tstate_lock = None
|
||||
self._started = Event()
|
||||
self._is_stopped = False
|
||||
|
@ -893,9 +891,6 @@ class Thread:
|
|||
def _set_ident(self):
|
||||
self._ident = get_ident()
|
||||
|
||||
def _set_native_id(self):
|
||||
self._native_id = get_native_id()
|
||||
|
||||
def _set_tstate_lock(self):
|
||||
"""
|
||||
Set a lock object which will be released by the interpreter when
|
||||
|
@ -908,7 +903,6 @@ class Thread:
|
|||
try:
|
||||
self._set_ident()
|
||||
self._set_tstate_lock()
|
||||
self._set_native_id()
|
||||
self._started.set()
|
||||
with _active_limbo_lock:
|
||||
_active[self._ident] = self
|
||||
|
@ -1083,17 +1077,6 @@ class Thread:
|
|||
assert self._initialized, "Thread.__init__() not called"
|
||||
return self._ident
|
||||
|
||||
@property
|
||||
def native_id(self):
|
||||
"""Native integral thread ID of this thread or 0 if it has not been started.
|
||||
|
||||
This is a non-negative integer. See the get_native_id() function.
|
||||
This represents the Thread ID as reported by the kernel.
|
||||
|
||||
"""
|
||||
assert self._initialized, "Thread.__init__() not called"
|
||||
return self._native_id
|
||||
|
||||
def is_alive(self):
|
||||
"""Return whether the thread is alive.
|
||||
|
||||
|
@ -1193,7 +1176,6 @@ class _MainThread(Thread):
|
|||
self._set_tstate_lock()
|
||||
self._started.set()
|
||||
self._set_ident()
|
||||
self._set_native_id()
|
||||
with _active_limbo_lock:
|
||||
_active[self._ident] = self
|
||||
|
||||
|
@ -1213,7 +1195,6 @@ class _DummyThread(Thread):
|
|||
|
||||
self._started.set()
|
||||
self._set_ident()
|
||||
self._set_native_id()
|
||||
with _active_limbo_lock:
|
||||
_active[self._ident] = self
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue