diff options
author | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2006-06-04 12:31:09 (GMT) |
---|---|---|
committer | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2006-06-04 12:31:09 (GMT) |
commit | 6539d2d3c758b507f10779e218d52d6c9f355025 (patch) | |
tree | d3677cd901f44e2341a50be45d8a3d2f6d1f4da6 /Lib/test/test_thread.py | |
parent | 7a071939d96702e13c377a5e7f87df7bf20391e5 (diff) | |
download | cpython-6539d2d3c758b507f10779e218d52d6c9f355025.zip cpython-6539d2d3c758b507f10779e218d52d6c9f355025.tar.gz cpython-6539d2d3c758b507f10779e218d52d6c9f355025.tar.bz2 |
Patch #1454481: Make thread stack size runtime tunable.
Diffstat (limited to 'Lib/test/test_thread.py')
-rw-r--r-- | Lib/test/test_thread.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index ea345b6..d970107 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -115,3 +115,38 @@ for i in range(numtasks): thread.start_new_thread(task2, (i,)) done.acquire() print 'all tasks done' + +# not all platforms support changing thread stack size +print '\n*** Changing thread stack size ***' +if thread.stack_size() != 0: + raise ValueError, "initial stack_size not 0" + +thread.stack_size(0) +if thread.stack_size() != 0: + raise ValueError, "stack_size not reset to default" + +from os import name as os_name +if os_name in ("nt", "os2", "posix"): + + for tss, ok in ((4096, 0), (32768, 1), (0x400000, 1), (0, 1)): + if ok: + failed = lambda s, e: s != e + fail_msg = "stack_size(%d) failed - should succeed" + else: + failed = lambda s, e: s == e + fail_msg = "stack_size(%d) succeeded - should fail" + thread.stack_size(tss) + if failed(thread.stack_size(), tss): + raise ValueError, fail_msg % tss + + for tss in (32768, 0x400000): + print 'trying stack_size = %d' % tss + next_ident = 0 + for i in range(numtasks): + newtask() + + print 'waiting for all tasks to complete' + done.acquire() + print 'all tasks done' + + thread.stack_size(0) |