blob: 71a88445245e07904e8c9334af736fdeb4ad0e3d [file] [log] [blame]
Skip Montanaro4533f602001-08-20 20:28:48 +00001# Very rudimentary test of threading module
2
Tim Peters84d54892005-01-08 06:03:17 +00003import test.test_support
Barry Warsaw04f357c2002-07-23 19:04:11 +00004from test.test_support import verbose
Skip Montanaro4533f602001-08-20 20:28:48 +00005import random
Gregory P. Smith8856dda2008-06-01 23:48:47 +00006import re
Collin Winter50b79ce2007-06-06 00:17:35 +00007import sys
Skip Montanaro4533f602001-08-20 20:28:48 +00008import threading
Tim Peters711906e2005-01-08 07:30:42 +00009import thread
Skip Montanaro4533f602001-08-20 20:28:48 +000010import time
Tim Peters84d54892005-01-08 06:03:17 +000011import unittest
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +000012import weakref
Skip Montanaro4533f602001-08-20 20:28:48 +000013
Tim Peters84d54892005-01-08 06:03:17 +000014# A trivial mutable counter.
15class Counter(object):
16 def __init__(self):
17 self.value = 0
18 def inc(self):
19 self.value += 1
20 def dec(self):
21 self.value -= 1
22 def get(self):
23 return self.value
Skip Montanaro4533f602001-08-20 20:28:48 +000024
25class TestThread(threading.Thread):
Tim Peters84d54892005-01-08 06:03:17 +000026 def __init__(self, name, testcase, sema, mutex, nrunning):
27 threading.Thread.__init__(self, name=name)
28 self.testcase = testcase
29 self.sema = sema
30 self.mutex = mutex
31 self.nrunning = nrunning
32
Skip Montanaro4533f602001-08-20 20:28:48 +000033 def run(self):
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000034 delay = random.random() / 10000.0
Skip Montanaro4533f602001-08-20 20:28:48 +000035 if verbose:
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000036 print 'task %s will run for %.1f usec' % (
Benjamin Petersoncbae8692008-08-18 17:45:09 +000037 self.name, delay * 1e6)
Tim Peters84d54892005-01-08 06:03:17 +000038
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000039 with self.sema:
40 with self.mutex:
41 self.nrunning.inc()
42 if verbose:
43 print self.nrunning.get(), 'tasks are running'
Benjamin Peterson5c8da862009-06-30 22:57:08 +000044 self.testcase.assertTrue(self.nrunning.get() <= 3)
Tim Peters84d54892005-01-08 06:03:17 +000045
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000046 time.sleep(delay)
47 if verbose:
Benjamin Petersoncbae8692008-08-18 17:45:09 +000048 print 'task', self.name, 'done'
Tim Peters84d54892005-01-08 06:03:17 +000049
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000050 with self.mutex:
51 self.nrunning.dec()
Benjamin Peterson5c8da862009-06-30 22:57:08 +000052 self.testcase.assertTrue(self.nrunning.get() >= 0)
Jeffrey Yasskin510eab52008-03-21 18:48:04 +000053 if verbose:
54 print '%s is finished. %d tasks are running' % (
Benjamin Petersoncbae8692008-08-18 17:45:09 +000055 self.name, self.nrunning.get())
Skip Montanaro4533f602001-08-20 20:28:48 +000056
Tim Peters84d54892005-01-08 06:03:17 +000057class ThreadTests(unittest.TestCase):
Skip Montanaro4533f602001-08-20 20:28:48 +000058
Tim Peters84d54892005-01-08 06:03:17 +000059 # Create a bunch of threads, let each do some work, wait until all are
60 # done.
61 def test_various_ops(self):
62 # This takes about n/3 seconds to run (about n/3 clumps of tasks,
63 # times about 1 second per clump).
64 NUMTASKS = 10
65
66 # no more than 3 of the 10 can run at once
67 sema = threading.BoundedSemaphore(value=3)
68 mutex = threading.RLock()
69 numrunning = Counter()
70
71 threads = []
72
73 for i in range(NUMTASKS):
74 t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
75 threads.append(t)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000076 self.assertEqual(t.ident, None)
77 self.assertTrue(re.match('<TestThread\(.*, initial\)>', repr(t)))
Tim Peters84d54892005-01-08 06:03:17 +000078 t.start()
79
80 if verbose:
81 print 'waiting for all tasks to complete'
82 for t in threads:
Tim Peters711906e2005-01-08 07:30:42 +000083 t.join(NUMTASKS)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000084 self.assertTrue(not t.is_alive())
85 self.assertNotEqual(t.ident, 0)
Benjamin Petersond906ea62009-03-31 21:34:42 +000086 self.assertFalse(t.ident is None)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000087 self.assertTrue(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
Tim Peters84d54892005-01-08 06:03:17 +000088 if verbose:
89 print 'all tasks done'
90 self.assertEqual(numrunning.get(), 0)
91
Benjamin Petersond906ea62009-03-31 21:34:42 +000092 def test_ident_of_no_threading_threads(self):
93 # The ident still must work for the main thread and dummy threads.
94 self.assertFalse(threading.currentThread().ident is None)
95 def f():
96 ident.append(threading.currentThread().ident)
97 done.set()
98 done = threading.Event()
99 ident = []
100 thread.start_new_thread(f, ())
101 done.wait()
102 self.assertFalse(ident[0] is None)
103
Andrew MacIntyre93e3ecb2006-06-13 19:02:35 +0000104 # run with a small(ish) thread stack size (256kB)
Andrew MacIntyre92913322006-06-13 15:04:24 +0000105 def test_various_ops_small_stack(self):
106 if verbose:
Andrew MacIntyre93e3ecb2006-06-13 19:02:35 +0000107 print 'with 256kB thread stack size...'
Andrew MacIntyre16ee33a2006-08-06 12:37:03 +0000108 try:
109 threading.stack_size(262144)
110 except thread.error:
111 if verbose:
112 print 'platform does not support changing thread stack size'
113 return
Andrew MacIntyre92913322006-06-13 15:04:24 +0000114 self.test_various_ops()
115 threading.stack_size(0)
116
117 # run with a large thread stack size (1MB)
118 def test_various_ops_large_stack(self):
119 if verbose:
120 print 'with 1MB thread stack size...'
Andrew MacIntyre16ee33a2006-08-06 12:37:03 +0000121 try:
122 threading.stack_size(0x100000)
123 except thread.error:
124 if verbose:
125 print 'platform does not support changing thread stack size'
126 return
Andrew MacIntyre92913322006-06-13 15:04:24 +0000127 self.test_various_ops()
128 threading.stack_size(0)
129
Tim Peters711906e2005-01-08 07:30:42 +0000130 def test_foreign_thread(self):
131 # Check that a "foreign" thread can use the threading module.
132 def f(mutex):
133 # Acquiring an RLock forces an entry for the foreign
134 # thread to get made in the threading._active map.
135 r = threading.RLock()
136 r.acquire()
137 r.release()
138 mutex.release()
139
140 mutex = threading.Lock()
141 mutex.acquire()
142 tid = thread.start_new_thread(f, (mutex,))
143 # Wait for the thread to finish.
144 mutex.acquire()
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000145 self.assertTrue(tid in threading._active)
146 self.assertTrue(isinstance(threading._active[tid],
Tim Peters711906e2005-01-08 07:30:42 +0000147 threading._DummyThread))
148 del threading._active[tid]
Tim Peters84d54892005-01-08 06:03:17 +0000149
Tim Peters4643c2f2006-08-10 22:45:34 +0000150 # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
151 # exposed at the Python level. This test relies on ctypes to get at it.
152 def test_PyThreadState_SetAsyncExc(self):
153 try:
154 import ctypes
155 except ImportError:
156 if verbose:
157 print "test_PyThreadState_SetAsyncExc can't import ctypes"
158 return # can't do anything
159
160 set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc
161
162 class AsyncExc(Exception):
163 pass
164
165 exception = ctypes.py_object(AsyncExc)
166
Antoine Pitrou8a172b12009-10-18 18:22:04 +0000167 # First check it works when setting the exception from the same thread.
168 tid = thread.get_ident()
169
170 try:
171 result = set_async_exc(ctypes.c_long(tid), exception)
172 # The exception is async, so we might have to keep the VM busy until
173 # it notices.
174 while True:
175 pass
176 except AsyncExc:
177 pass
178 else:
Antoine Pitrou603acf92009-10-18 18:37:11 +0000179 # This code is unreachable but it reflects the intent. If we wanted
180 # to be smarter the above loop wouldn't be infinite.
Antoine Pitrou8a172b12009-10-18 18:22:04 +0000181 self.fail("AsyncExc not raised")
182 try:
183 self.assertEqual(result, 1) # one thread state modified
184 except UnboundLocalError:
Antoine Pitrou603acf92009-10-18 18:37:11 +0000185 # The exception was raised too quickly for us to get the result.
Antoine Pitrou8a172b12009-10-18 18:22:04 +0000186 pass
187
Tim Peters4643c2f2006-08-10 22:45:34 +0000188 # `worker_started` is set by the thread when it's inside a try/except
189 # block waiting to catch the asynchronously set AsyncExc exception.
190 # `worker_saw_exception` is set by the thread upon catching that
191 # exception.
192 worker_started = threading.Event()
193 worker_saw_exception = threading.Event()
194
195 class Worker(threading.Thread):
196 def run(self):
197 self.id = thread.get_ident()
198 self.finished = False
199
200 try:
201 while True:
202 worker_started.set()
203 time.sleep(0.1)
204 except AsyncExc:
205 self.finished = True
206 worker_saw_exception.set()
207
208 t = Worker()
Benjamin Petersoncbae8692008-08-18 17:45:09 +0000209 t.daemon = True # so if this fails, we don't hang Python at shutdown
Tim Peters08574772006-08-11 00:49:01 +0000210 t.start()
Tim Peters4643c2f2006-08-10 22:45:34 +0000211 if verbose:
212 print " started worker thread"
Tim Peters4643c2f2006-08-10 22:45:34 +0000213
214 # Try a thread id that doesn't make sense.
215 if verbose:
216 print " trying nonsensical thread id"
Tim Peters08574772006-08-11 00:49:01 +0000217 result = set_async_exc(ctypes.c_long(-1), exception)
Tim Peters4643c2f2006-08-10 22:45:34 +0000218 self.assertEqual(result, 0) # no thread states modified
219
220 # Now raise an exception in the worker thread.
221 if verbose:
222 print " waiting for worker thread to get started"
Georg Brandlef660e82009-03-31 20:41:08 +0000223 ret = worker_started.wait()
224 self.assertTrue(ret)
Tim Peters4643c2f2006-08-10 22:45:34 +0000225 if verbose:
226 print " verifying worker hasn't exited"
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000227 self.assertTrue(not t.finished)
Tim Peters4643c2f2006-08-10 22:45:34 +0000228 if verbose:
229 print " attempting to raise asynch exception in worker"
Tim Peters08574772006-08-11 00:49:01 +0000230 result = set_async_exc(ctypes.c_long(t.id), exception)
Tim Peters4643c2f2006-08-10 22:45:34 +0000231 self.assertEqual(result, 1) # one thread state modified
232 if verbose:
233 print " waiting for worker to say it caught the exception"
234 worker_saw_exception.wait(timeout=10)
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000235 self.assertTrue(t.finished)
Tim Peters4643c2f2006-08-10 22:45:34 +0000236 if verbose:
237 print " all OK -- joining worker"
238 if t.finished:
239 t.join()
240 # else the thread is still running, and we have no way to kill it
241
Amaury Forgeot d'Arc025c3472007-11-29 23:35:25 +0000242 def test_finalize_runnning_thread(self):
243 # Issue 1402: the PyGILState_Ensure / _Release functions may be called
244 # very late on python exit: on deallocation of a running thread for
245 # example.
246 try:
247 import ctypes
248 except ImportError:
249 if verbose:
250 print("test_finalize_with_runnning_thread can't import ctypes")
251 return # can't do anything
252
253 import subprocess
254 rc = subprocess.call([sys.executable, "-c", """if 1:
255 import ctypes, sys, time, thread
256
Jeffrey Yasskin510eab52008-03-21 18:48:04 +0000257 # This lock is used as a simple event variable.
258 ready = thread.allocate_lock()
259 ready.acquire()
260
Amaury Forgeot d'Arc025c3472007-11-29 23:35:25 +0000261 # Module globals are cleared before __del__ is run
262 # So we save the functions in class dict
263 class C:
264 ensure = ctypes.pythonapi.PyGILState_Ensure
265 release = ctypes.pythonapi.PyGILState_Release
266 def __del__(self):
267 state = self.ensure()
268 self.release(state)
269
270 def waitingThread():
271 x = C()
Jeffrey Yasskin510eab52008-03-21 18:48:04 +0000272 ready.release()
Amaury Forgeot d'Arc025c3472007-11-29 23:35:25 +0000273 time.sleep(100)
274
275 thread.start_new_thread(waitingThread, ())
Jeffrey Yasskin510eab52008-03-21 18:48:04 +0000276 ready.acquire() # Be sure the other thread is waiting.
Amaury Forgeot d'Arc025c3472007-11-29 23:35:25 +0000277 sys.exit(42)
278 """])
279 self.assertEqual(rc, 42)
280
Amaury Forgeot d'Arcd7a26512008-04-03 23:07:55 +0000281 def test_finalize_with_trace(self):
282 # Issue1733757
283 # Avoid a deadlock when sys.settrace steps into threading._shutdown
284 import subprocess
285 rc = subprocess.call([sys.executable, "-c", """if 1:
286 import sys, threading
287
288 # A deadlock-killer, to prevent the
289 # testsuite to hang forever
290 def killer():
291 import os, time
292 time.sleep(2)
293 print 'program blocked; aborting'
294 os._exit(2)
295 t = threading.Thread(target=killer)
Benjamin Petersoncbae8692008-08-18 17:45:09 +0000296 t.daemon = True
Amaury Forgeot d'Arcd7a26512008-04-03 23:07:55 +0000297 t.start()
298
299 # This is the trace function
300 def func(frame, event, arg):
Benjamin Peterson0fbcf692008-06-11 17:27:50 +0000301 threading.current_thread()
Amaury Forgeot d'Arcd7a26512008-04-03 23:07:55 +0000302 return func
303
304 sys.settrace(func)
305 """])
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000306 self.assertFalse(rc == 2, "interpreted was blocked")
307 self.assertTrue(rc == 0, "Unexpected error")
Amaury Forgeot d'Arcd7a26512008-04-03 23:07:55 +0000308
Antoine Pitrouefb60c02009-10-20 21:29:37 +0000309 def test_join_nondaemon_on_shutdown(self):
310 # Issue 1722344
311 # Raising SystemExit skipped threading._shutdown
312 import subprocess
313 p = subprocess.Popen([sys.executable, "-c", """if 1:
314 import threading
315 from time import sleep
316
317 def child():
318 sleep(1)
319 # As a non-daemon thread we SHOULD wake up and nothing
320 # should be torn down yet
321 print "Woke up, sleep function is:", sleep
322
323 threading.Thread(target=child).start()
324 raise SystemExit
325 """],
326 stdout=subprocess.PIPE,
327 stderr=subprocess.PIPE)
328 stdout, stderr = p.communicate()
Antoine Pitroub119ca92009-10-23 12:01:13 +0000329 self.assertEqual(stdout.strip(),
330 "Woke up, sleep function is: <built-in function sleep>")
Antoine Pitrou9bd246b2009-10-20 21:59:25 +0000331 stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip()
Antoine Pitrouefb60c02009-10-20 21:29:37 +0000332 self.assertEqual(stderr, "")
333
Gregory P. Smith95cd5c02008-01-22 01:20:42 +0000334 def test_enumerate_after_join(self):
335 # Try hard to trigger #1703448: a thread is still returned in
336 # threading.enumerate() after it has been join()ed.
337 enum = threading.enumerate
338 old_interval = sys.getcheckinterval()
Gregory P. Smith95cd5c02008-01-22 01:20:42 +0000339 try:
Jeffrey Yasskin510eab52008-03-21 18:48:04 +0000340 for i in xrange(1, 100):
341 # Try a couple times at each thread-switching interval
342 # to get more interleavings.
343 sys.setcheckinterval(i // 5)
Gregory P. Smith95cd5c02008-01-22 01:20:42 +0000344 t = threading.Thread(target=lambda: None)
345 t.start()
346 t.join()
347 l = enum()
348 self.assertFalse(t in l,
349 "#1703448 triggered after %d trials: %s" % (i, l))
350 finally:
351 sys.setcheckinterval(old_interval)
352
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000353 def test_no_refcycle_through_target(self):
354 class RunSelfFunction(object):
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000355 def __init__(self, should_raise):
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000356 # The links in this refcycle from Thread back to self
357 # should be cleaned up when the thread completes.
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000358 self.should_raise = should_raise
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000359 self.thread = threading.Thread(target=self._run,
360 args=(self,),
361 kwargs={'yet_another':self})
362 self.thread.start()
363
364 def _run(self, other_ref, yet_another):
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000365 if self.should_raise:
366 raise SystemExit
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000367
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000368 cyclic_object = RunSelfFunction(should_raise=False)
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000369 weak_cyclic_object = weakref.ref(cyclic_object)
370 cyclic_object.thread.join()
371 del cyclic_object
Jeffrey Yasskin8b9091f2008-03-28 04:11:18 +0000372 self.assertEquals(None, weak_cyclic_object(),
373 msg=('%d references still around' %
374 sys.getrefcount(weak_cyclic_object())))
Jeffrey Yasskin3414ea92008-02-23 19:40:54 +0000375
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000376 raising_cyclic_object = RunSelfFunction(should_raise=True)
377 weak_raising_cyclic_object = weakref.ref(raising_cyclic_object)
378 raising_cyclic_object.thread.join()
379 del raising_cyclic_object
Jeffrey Yasskin8b9091f2008-03-28 04:11:18 +0000380 self.assertEquals(None, weak_raising_cyclic_object(),
381 msg=('%d references still around' %
382 sys.getrefcount(weak_raising_cyclic_object())))
Jeffrey Yasskina885c152008-02-23 20:40:35 +0000383
Gregory P. Smith95cd5c02008-01-22 01:20:42 +0000384
Jesse Noller5e62ca42008-07-16 20:03:47 +0000385class ThreadJoinOnShutdown(unittest.TestCase):
386
387 def _run_and_join(self, script):
388 script = """if 1:
389 import sys, os, time, threading
390
391 # a thread, which waits for the main program to terminate
392 def joiningfunc(mainthread):
393 mainthread.join()
394 print 'end of thread'
395 \n""" + script
396
397 import subprocess
398 p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE)
399 rc = p.wait()
Benjamin Petersonf5668f12008-07-17 12:57:22 +0000400 data = p.stdout.read().replace('\r', '')
401 self.assertEqual(data, "end of main\nend of thread\n")
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000402 self.assertFalse(rc == 2, "interpreter was blocked")
403 self.assertTrue(rc == 0, "Unexpected error")
Jesse Noller5e62ca42008-07-16 20:03:47 +0000404
405 def test_1_join_on_shutdown(self):
406 # The usual case: on exit, wait for a non-daemon thread
407 script = """if 1:
408 import os
409 t = threading.Thread(target=joiningfunc,
410 args=(threading.current_thread(),))
411 t.start()
412 time.sleep(0.1)
413 print 'end of main'
414 """
415 self._run_and_join(script)
416
417
418 def test_2_join_in_forked_process(self):
419 # Like the test above, but from a forked interpreter
420 import os
421 if not hasattr(os, 'fork'):
422 return
423 script = """if 1:
424 childpid = os.fork()
425 if childpid != 0:
426 os.waitpid(childpid, 0)
427 sys.exit(0)
428
429 t = threading.Thread(target=joiningfunc,
430 args=(threading.current_thread(),))
431 t.start()
432 print 'end of main'
433 """
434 self._run_and_join(script)
435
436 def test_3_join_in_forked_from_thread(self):
437 # Like the test above, but fork() was called from a worker thread
438 # In the forked process, the main Thread object must be marked as stopped.
439 import os
440 if not hasattr(os, 'fork'):
441 return
Gregory P. Smith08067492008-09-30 20:41:13 +0000442 # Skip platforms with known problems forking from a worker thread.
443 # See http://bugs.python.org/issue3863.
444 if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
445 print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread'
446 ' due to known OS bugs on'), sys.platform
447 return
Jesse Noller5e62ca42008-07-16 20:03:47 +0000448 script = """if 1:
449 main_thread = threading.current_thread()
450 def worker():
451 childpid = os.fork()
452 if childpid != 0:
453 os.waitpid(childpid, 0)
454 sys.exit(0)
455
456 t = threading.Thread(target=joiningfunc,
457 args=(main_thread,))
458 print 'end of main'
459 t.start()
460 t.join() # Should not block: main_thread is already stopped
461
462 w = threading.Thread(target=worker)
463 w.start()
464 """
465 self._run_and_join(script)
466
467
Collin Winter50b79ce2007-06-06 00:17:35 +0000468class ThreadingExceptionTests(unittest.TestCase):
469 # A RuntimeError should be raised if Thread.start() is called
470 # multiple times.
471 def test_start_thread_again(self):
472 thread = threading.Thread()
473 thread.start()
474 self.assertRaises(RuntimeError, thread.start)
475
476 def test_releasing_unacquired_rlock(self):
477 rlock = threading.RLock()
478 self.assertRaises(RuntimeError, rlock.release)
479
480 def test_waiting_on_unacquired_condition(self):
481 cond = threading.Condition()
482 self.assertRaises(RuntimeError, cond.wait)
483
484 def test_notify_on_unacquired_condition(self):
485 cond = threading.Condition()
486 self.assertRaises(RuntimeError, cond.notify)
487
488 def test_semaphore_with_negative_value(self):
489 self.assertRaises(ValueError, threading.Semaphore, value = -1)
490 self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint)
491
492 def test_joining_current_thread(self):
Benjamin Peterson0fbcf692008-06-11 17:27:50 +0000493 current_thread = threading.current_thread()
494 self.assertRaises(RuntimeError, current_thread.join);
Collin Winter50b79ce2007-06-06 00:17:35 +0000495
496 def test_joining_inactive_thread(self):
497 thread = threading.Thread()
498 self.assertRaises(RuntimeError, thread.join)
499
500 def test_daemonize_active_thread(self):
501 thread = threading.Thread()
502 thread.start()
Benjamin Petersoncbae8692008-08-18 17:45:09 +0000503 self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
Collin Winter50b79ce2007-06-06 00:17:35 +0000504
505
Tim Peters84d54892005-01-08 06:03:17 +0000506def test_main():
Collin Winter50b79ce2007-06-06 00:17:35 +0000507 test.test_support.run_unittest(ThreadTests,
Jesse Noller5e62ca42008-07-16 20:03:47 +0000508 ThreadJoinOnShutdown,
509 ThreadingExceptionTests,
510 )
Tim Peters84d54892005-01-08 06:03:17 +0000511
512if __name__ == "__main__":
513 test_main()