diff options
author | Georg Brandl <georg@python.org> | 2008-05-25 13:05:15 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-25 13:05:15 (GMT) |
commit | 2067bfdf253e134a4144d3747300dbfcc7cc6203 (patch) | |
tree | 76613f07319d07cc4f0159769131a051504f8c69 /Lib/test | |
parent | 3b4b45bfe546b023383d4382af7767359390e264 (diff) | |
download | cpython-2067bfdf253e134a4144d3747300dbfcc7cc6203.zip cpython-2067bfdf253e134a4144d3747300dbfcc7cc6203.tar.gz cpython-2067bfdf253e134a4144d3747300dbfcc7cc6203.tar.bz2 |
Rename thread to _thread and dummy_thread to _dummy_thread. Issue #2875.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/crashers/multithreaded_close.py | 4 | ||||
-rw-r--r-- | Lib/test/fork_wait.py | 4 | ||||
-rw-r--r-- | Lib/test/test___all__.py | 2 | ||||
-rw-r--r-- | Lib/test/test_asynchat.py | 2 | ||||
-rw-r--r-- | Lib/test/test_capi.py | 8 | ||||
-rw-r--r-- | Lib/test/test_dummy_thread.py | 6 | ||||
-rw-r--r-- | Lib/test/test_socket.py | 3 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 8 | ||||
-rw-r--r-- | Lib/test/test_thread.py | 2 | ||||
-rw-r--r-- | Lib/test/test_threaded_import.py | 2 | ||||
-rw-r--r-- | Lib/test/test_threadedtempfile.py | 2 | ||||
-rw-r--r-- | Lib/test/test_threading.py | 18 | ||||
-rw-r--r-- | Lib/test/test_threadsignals.py | 2 |
13 files changed, 32 insertions, 31 deletions
diff --git a/Lib/test/crashers/multithreaded_close.py b/Lib/test/crashers/multithreaded_close.py index 5224341..f862d28 100644 --- a/Lib/test/crashers/multithreaded_close.py +++ b/Lib/test/crashers/multithreaded_close.py @@ -6,9 +6,9 @@ # http://bugs.python.org/issue595601 # http://bugs.python.org/issue815646 -import thread +import _thread while 1: f = open("multithreaded_close.tmp", "w") - thread.start_new_thread(f.close, ()) + _thread.start_new_thread(f.close, ()) f.close() diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py index 678e3c4..03a4d6f 100644 --- a/Lib/test/fork_wait.py +++ b/Lib/test/fork_wait.py @@ -9,7 +9,7 @@ On some systems (e.g. Solaris without posix threads) we find that all active threads survive in the child after a fork(); this is an error. """ -import os, sys, time, thread, unittest +import os, sys, time, _thread, unittest LONGSLEEP = 2 SHORTSLEEP = 0.5 @@ -43,7 +43,7 @@ class ForkWait(unittest.TestCase): def test_wait(self): for i in range(NUM_THREADS): - thread.start_new(self.f, (i,)) + _thread.start_new(self.f, (i,)) time.sleep(LONGSLEEP) diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index c58aead..615f6c5 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -63,7 +63,7 @@ class AllTest(unittest.TestCase): self.check_all("dircache") self.check_all("dis") self.check_all("doctest") - self.check_all("dummy_thread") + self.check_all("_dummy_thread") self.check_all("dummy_threading") self.check_all("filecmp") self.check_all("fileinput") diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py index 4d49f58..082fde9 100644 --- a/Lib/test/test_asynchat.py +++ b/Lib/test/test_asynchat.py @@ -1,6 +1,6 @@ # test asynchat -- requires threading -import thread # If this fails, we can't test this module +import _thread as thread # If this fails, we can't test this module import asyncore, asynchat, socket, threading, time import unittest import sys diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index df5ce0b..6c87645 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -22,13 +22,13 @@ def test_main(): idents = [] def callback(): - idents.append(thread.get_ident()) + idents.append(_thread.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(_thread.get_ident()) != 3: raise support.TestFailed( "Couldn't find main thread correctly in the list") @@ -39,11 +39,11 @@ def test_main(): have_thread_state = False if have_thread_state: - import thread + import _thread import time TestThreadState() import threading - t=threading.Thread(target=TestThreadState) + t = threading.Thread(target=TestThreadState) t.start() t.join() diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py index 585711f..5b7db18 100644 --- a/Lib/test/test_dummy_thread.py +++ b/Lib/test/test_dummy_thread.py @@ -5,15 +5,15 @@ to be used, test_main() can be called with the module to use as the thread implementation as its sole argument. """ -import dummy_thread as _thread +import _dummy_thread as _thread import time import queue import random import unittest from test import support -DELAY = 0 # Set > 0 when testing a module other than dummy_thread, such as - # the 'thread' module. +DELAY = 0 # Set > 0 when testing a module other than _dummy_thread, such as + # the '_thread' module. class LockTests(unittest.TestCase): """Test lock objects.""" diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 349548f..d12968c 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -6,7 +6,8 @@ from test import support import errno import socket import select -import thread, threading +import _thread as thread +import threading import time import traceback import queue diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 7c66e0d..231b460 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -191,7 +191,7 @@ class SysModuleTest(unittest.TestCase): def test_current_frames(self): have_threads = True try: - import thread + import _thread except ImportError: have_threads = False @@ -202,7 +202,7 @@ class SysModuleTest(unittest.TestCase): # Test sys._current_frames() in a WITH_THREADS build. def current_frames_with_threads(self): - import threading, thread + import threading, _thread import traceback # Spawn a thread that blocks at a known place. Then the main @@ -216,7 +216,7 @@ class SysModuleTest(unittest.TestCase): g456() def g456(): - thread_info.append(thread.get_ident()) + thread_info.append(_thread.get_ident()) entered_g.set() leave_g.wait() @@ -232,7 +232,7 @@ class SysModuleTest(unittest.TestCase): d = sys._current_frames() - main_id = thread.get_ident() + main_id = _thread.get_ident() self.assert_(main_id in d) self.assert_(thread_id in d) diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index cff9f81..84d5a9d 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -2,7 +2,7 @@ import os import unittest import random from test import support -import thread +import _thread as thread import time diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index fbe479c..67d1505 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -5,7 +5,7 @@ # complains several times about module random having no attribute # randrange, and then Python hangs. -import thread +import _thread as thread from test.support import verbose, TestSkipped, TestFailed critical_section = thread.allocate_lock() diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py index fb122d0..d93b382 100644 --- a/Lib/test/test_threadedtempfile.py +++ b/Lib/test/test_threadedtempfile.py @@ -16,7 +16,7 @@ provoking a 2.0 failure under Linux. NUM_THREADS = 20 FILES_PER_THREAD = 50 -import thread # If this fails, we can't test this module +import _thread as thread # If this fails, we can't test this module import threading import tempfile diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 9582dde..3c09b0b 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -5,7 +5,7 @@ from test.support import verbose import random import sys import threading -import thread +import _thread import time import unittest import weakref @@ -88,7 +88,7 @@ class ThreadTests(unittest.TestCase): print('with 256kB thread stack size...') try: threading.stack_size(262144) - except thread.error: + except _thread.error: if verbose: print('platform does not support changing thread stack size') return @@ -101,7 +101,7 @@ class ThreadTests(unittest.TestCase): print('with 1MB thread stack size...') try: threading.stack_size(0x100000) - except thread.error: + except _thread.error: if verbose: print('platform does not support changing thread stack size') return @@ -120,7 +120,7 @@ class ThreadTests(unittest.TestCase): mutex = threading.Lock() mutex.acquire() - tid = thread.start_new_thread(f, (mutex,)) + tid = _thread.start_new_thread(f, (mutex,)) # Wait for the thread to finish. mutex.acquire() self.assert_(tid in threading._active) @@ -154,7 +154,7 @@ class ThreadTests(unittest.TestCase): class Worker(threading.Thread): def run(self): - self.id = thread.get_ident() + self.id = _thread.get_ident() self.finished = False try: @@ -211,10 +211,10 @@ class ThreadTests(unittest.TestCase): import subprocess rc = subprocess.call([sys.executable, "-c", """if 1: - import ctypes, sys, time, thread + import ctypes, sys, time, _thread # This lock is used as a simple event variable. - ready = thread.allocate_lock() + ready = _thread.allocate_lock() ready.acquire() # Module globals are cleared before __del__ is run @@ -231,7 +231,7 @@ class ThreadTests(unittest.TestCase): ready.release() time.sleep(100) - thread.start_new_thread(waitingThread, ()) + _thread.start_new_thread(waitingThread, ()) ready.acquire() # Be sure the other thread is waiting. sys.exit(42) """]) @@ -357,7 +357,7 @@ class ThreadingExceptionTests(unittest.TestCase): def test_main(): test.support.run_unittest(ThreadTests, - ThreadingExceptionTests) + ThreadingExceptionTests) if __name__ == "__main__": test_main() diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py index cbed42c..14bd3b7 100644 --- a/Lib/test/test_threadsignals.py +++ b/Lib/test/test_threadsignals.py @@ -1,7 +1,7 @@ """PyUnit testing that threads honor our signal semantics""" import unittest -import thread +import _thread as thread import signal import os import sys |