當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。