Python _thread.stack_size() Examples

The following are 15 code examples of _thread.stack_size(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _thread , or try the search function .
Example #1
Source File: test_thread.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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) 
Example #2
Source File: microWebSrv2.py    From MicroWebSrv2 with MIT License 5 votes vote down vote up
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

    # ------------------------------------------------------------------------ 
Example #3
Source File: _dummy_thread.py    From jawfish with MIT License 5 votes vote down vote up
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 
Example #4
Source File: _thread.py    From jawfish with MIT License 5 votes vote down vote up
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 
Example #5
Source File: _dummy_thread.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 
Example #6
Source File: thread.py    From satori with Apache License 2.0 5 votes vote down vote up
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 
Example #7
Source File: _dummy_thread.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
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 
Example #8
Source File: _dummy_thread.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: _dummy_thread.py    From Imogen with MIT License 5 votes vote down vote up
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 
Example #10
Source File: _dummy_thread.py    From scylla with Apache License 2.0 5 votes vote down vote up
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 
Example #11
Source File: _dummy_thread.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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 
Example #12
Source File: _dummy_thread.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #13
Source File: thread.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
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 
Example #14
Source File: thread.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
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 
Example #15
Source File: _dummy_thread.py    From android_universal with MIT License 5 votes vote down vote up
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