diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-30 21:02:52 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-30 21:02:52 (GMT) |
commit | 2a12974bca2433eea0131d904a423ed8234dcf7a (patch) | |
tree | e238e53c319beb8f913e3411fa91a98504d1743d /Lib/test | |
parent | d976098e3bb53b9c52d55a303e1389a102ed8bae (diff) | |
download | cpython-2a12974bca2433eea0131d904a423ed8234dcf7a.zip cpython-2a12974bca2433eea0131d904a423ed8234dcf7a.tar.gz cpython-2a12974bca2433eea0131d904a423ed8234dcf7a.tar.bz2 |
Close #12028: Make threading._get_ident() public, rename it to
threading.get_ident() and document it. This function was used by
_thread.get_ident().
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/lock_tests.py | 4 | ||||
-rw-r--r-- | Lib/test/test_capi.py | 5 | ||||
-rw-r--r-- | Lib/test/test_signal.py | 4 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 6 | ||||
-rw-r--r-- | Lib/test/test_threaded_import.py | 2 | ||||
-rw-r--r-- | Lib/test/test_threading.py | 4 |
6 files changed, 12 insertions, 13 deletions
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index 126f97c..7bcc436 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -4,7 +4,7 @@ Various tests for synchronization primitives. import sys import time -from _thread import start_new_thread, get_ident, TIMEOUT_MAX +from _thread import start_new_thread, TIMEOUT_MAX import threading import unittest @@ -31,7 +31,7 @@ class Bunch(object): self.finished = [] self._can_exit = not wait_before_exit def task(): - tid = get_ident() + tid = threading.get_ident() self.started.append(tid) try: f() diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 327ac66..7236474 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -190,18 +190,17 @@ def test_main(): idents = [] def callback(): - idents.append(_thread.get_ident()) + idents.append(threading.get_ident()) _testcapi._test_thread_state(callback) a = b = callback time.sleep(1) # Check our main thread is in the list exactly 3 times. - if idents.count(_thread.get_ident()) != 3: + if idents.count(threading.get_ident()) != 3: raise support.TestFailed( "Couldn't find main thread correctly in the list") if threading: - import _thread import time TestThreadState() t = threading.Thread(target=TestThreadState) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index cdd3f3e..4bf2d2d 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -557,7 +557,7 @@ class PendingSignalsTests(unittest.TestCase): def kill(self, signum): if self.has_pthread_kill: - tid = threading.current_thread().ident + tid = threading.get_ident() signal.pthread_kill(tid, signum) else: pid = os.getpid() @@ -589,7 +589,7 @@ class PendingSignalsTests(unittest.TestCase): 'need signal.pthread_kill()') def test_pthread_kill(self): signum = signal.SIGUSR1 - current = threading.current_thread().ident + current = threading.get_ident() old_handler = signal.signal(signum, self.handler) self.addCleanup(signal.signal, signum, old_handler) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 04bdfef..bc0f34c 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -343,7 +343,7 @@ class SysModuleTest(unittest.TestCase): # Test sys._current_frames() in a WITH_THREADS build. @test.support.reap_threads def current_frames_with_threads(self): - import threading, _thread + import threading import traceback # Spawn a thread that blocks at a known place. Then the main @@ -357,7 +357,7 @@ class SysModuleTest(unittest.TestCase): g456() def g456(): - thread_info.append(_thread.get_ident()) + thread_info.append(threading.get_ident()) entered_g.set() leave_g.wait() @@ -373,7 +373,7 @@ class SysModuleTest(unittest.TestCase): d = sys._current_frames() - main_id = _thread.get_ident() + main_id = threading.get_ident() self.assertIn(main_id, d) self.assertIn(thread_id, d) diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index 7791935..6919d21 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -30,7 +30,7 @@ def task(N, done, done_tasks, errors): except Exception as e: errors.append(e.with_traceback(None)) finally: - done_tasks.append(thread.get_ident()) + done_tasks.append(threading.get_ident()) finished = len(done_tasks) == N if finished: done.set() diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index c22d965..12e596e 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -173,7 +173,7 @@ class ThreadTests(BaseTestCase): exception = ctypes.py_object(AsyncExc) # First check it works when setting the exception from the same thread. - tid = _thread.get_ident() + tid = threading.get_ident() try: result = set_async_exc(ctypes.c_long(tid), exception) @@ -202,7 +202,7 @@ class ThreadTests(BaseTestCase): class Worker(threading.Thread): def run(self): - self.id = _thread.get_ident() + self.id = threading.get_ident() self.finished = False try: |