当前位置: 首页>>代码示例>>Python>>正文


Python _thread.stack_size方法代码示例

本文整理汇总了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) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:25,代码来源:test_thread.py

示例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

    # ------------------------------------------------------------------------ 
开发者ID:jczic,项目名称:MicroWebSrv2,代码行数:33,代码来源:microWebSrv2.py

示例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 
开发者ID:war-and-code,项目名称:jawfish,代码行数:7,代码来源:_dummy_thread.py

示例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 
开发者ID:leancloud,项目名称:satori,代码行数:10,代码来源:thread.py


注:本文中的_thread.stack_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。