本文整理汇总了Python中_thread.stack_size方法的典型用法代码示例。如果您正苦于以下问题:Python _thread.stack_size方法的具体用法?Python _thread.stack_size怎么用?Python _thread.stack_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_thread
的用法示例。
在下文中一共展示了_thread.stack_size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stack_size
# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import stack_size [as 别名]
def test_stack_size(self):
import sys
if is_cli or (sys.version_info[0] == 2 and sys.version_info[1] > 4) or sys.version_info[0] > 2:
import _thread as thread
size = thread.stack_size()
self.assertTrue(size==0 or size>=32768)
bad_size_list = [ 1, -1, -32768, -32769, -32767, -40000, 32767, 32766]
for bad_size in bad_size_list:
self.assertRaises(ValueError, thread.stack_size, bad_size)
good_size_list = [4096*10, 4096*100, 4096*1000, 4096*10000]
for good_size in good_size_list:
#CodePlex Work Item 7827
if is_cli and good_size<=50000: print("Ignoring", good_size, "for CLI"); continue
temp = thread.stack_size(good_size)
self.assertTrue(temp>=32768 or temp==0)
def temp(): pass
thread.start_new_thread(temp, ())
temp = thread.stack_size(1024*1024)
self.assertTrue(temp>=32768 or temp==0)
示例2: StartManaged
# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import stack_size [as 别名]
def StartManaged(self, parllProcCount=1, procStackSize=0) :
if not isinstance(parllProcCount, int) or parllProcCount < 0 :
raise ValueError('"parllProcCount" must be a positive integer or zero.')
if not isinstance(procStackSize, int) or procStackSize < 0 :
raise ValueError('"procStackSize" must be a positive integer or zero.')
if self._xasSrv :
raise MicroWebSrv2Exception('Server is already running.')
if procStackSize == 0 and implementation.name == 'micropython' :
procStackSize = 8*1024
try :
saveStackSize = stack_size(procStackSize)
except Exception as ex :
raise ValueError('"procStackSize" of %s is not correct (%s).' % (procStackSize, ex))
self._xasPool = XAsyncSocketsPool()
try :
self.StartInPool(self._xasPool)
try :
self.Log('Starts the managed pool to wait for I/O events.', MicroWebSrv2.INFO)
self._xasPool.AsyncWaitEvents(threadsCount=parllProcCount)
except :
raise MicroWebSrv2Exception('Not enough memory to start %s parallel processes.' % parllProcCount)
except Exception as ex :
self.Stop()
raise ex
finally :
try :
stack_size(saveStackSize)
except :
pass
# ------------------------------------------------------------------------
示例3: stack_size
# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import stack_size [as 别名]
def stack_size(size=None):
"""Dummy implementation of _thread.stack_size()."""
if size is not None:
raise error("setting thread stack size not supported")
return 0
示例4: stack_size
# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import stack_size [as 别名]
def stack_size(size=None):
if size is None:
return _original_stack_size()
if size > _original_stack_size():
return _original_stack_size(size)
else:
pass
# not going to decrease stack_size, because otherwise other greenlets in this thread will suffer