mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Patch #1454481: Make thread stack size runtime tunable.
Heavily revised, comprising revisions: 46640 - original trunk revision (backed out in r46655) 46647 - markup fix (backed out in r46655) 46692:46918 merged from branch aimacintyre-sf1454481 branch tested on buildbots (Windows buildbots had problems not related to these changes).
This commit is contained in:
parent
c6f5b3ad6c
commit
9291332de1
14 changed files with 349 additions and 6 deletions
|
@ -115,3 +115,46 @@ 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"):
|
||||
|
||||
tss_supported = 1
|
||||
try:
|
||||
thread.stack_size(4096)
|
||||
except ValueError:
|
||||
print 'caught expected ValueError setting stack_size(4096)'
|
||||
except thread.ThreadError:
|
||||
tss_supported = 0
|
||||
print 'platform does not support changing thread stack size'
|
||||
|
||||
if tss_supported:
|
||||
failed = lambda s, e: s != e
|
||||
fail_msg = "stack_size(%d) failed - should succeed"
|
||||
for tss in (32768, 0x100000, 0):
|
||||
thread.stack_size(tss)
|
||||
if failed(thread.stack_size(), tss):
|
||||
raise ValueError, fail_msg % tss
|
||||
print 'successfully set stack_size(%d)' % tss
|
||||
|
||||
for tss in (32768, 0x100000):
|
||||
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'
|
||||
|
||||
# reset stack size to default
|
||||
thread.stack_size(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue