<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[_thread stacks size bug]]></title><description><![CDATA[<p dir="auto">In the documentation, it says that the command _thread.stack_size() with no argument returns the thread stack size used when creating new threads. I find that using this command resets the stack size to the default 0.</p>
<pre><code>import _thread
import utime

def printStack():
    tick = 0
    while  True:
        utime.sleep(1)
        print('stack size = {}'.format(_thread.stack_size()))

_thread.stack_size(12288)
_thread.start_new_thread(printStack, ())

</code></pre>
<p dir="auto">printout:</p>
<p dir="auto">stack size = 32768<br />
stack size = 0<br />
stack size = 0<br />
stack size = 0<br />
....</p>
<p dir="auto">So it appears the documentation is incorrect, and the command actually resets the stack size to 0.</p>
<p dir="auto">Bonus question: is there a recommended limit to how large a thread stack size should be? is there any downside in having It large?</p>
<p dir="auto">Thanks,<br />
Troy</p>
]]></description><link>https://forum.pycom.io/topic/5829/_thread-stacks-size-bug</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 05:59:20 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/5829.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Mar 2020 20:31:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to _thread stacks size bug on Wed, 25 Mar 2020 20:31:55 GMT]]></title><description><![CDATA[<p dir="auto">In the documentation, it says that the command _thread.stack_size() with no argument returns the thread stack size used when creating new threads. I find that using this command resets the stack size to the default 0.</p>
<pre><code>import _thread
import utime

def printStack():
    tick = 0
    while  True:
        utime.sleep(1)
        print('stack size = {}'.format(_thread.stack_size()))

_thread.stack_size(12288)
_thread.start_new_thread(printStack, ())

</code></pre>
<p dir="auto">printout:</p>
<p dir="auto">stack size = 32768<br />
stack size = 0<br />
stack size = 0<br />
stack size = 0<br />
....</p>
<p dir="auto">So it appears the documentation is incorrect, and the command actually resets the stack size to 0.</p>
<p dir="auto">Bonus question: is there a recommended limit to how large a thread stack size should be? is there any downside in having It large?</p>
<p dir="auto">Thanks,<br />
Troy</p>
]]></description><link>https://forum.pycom.io/post/32238</link><guid isPermaLink="true">https://forum.pycom.io/post/32238</guid><dc:creator><![CDATA[troy salt]]></dc:creator><pubDate>Wed, 25 Mar 2020 20:31:55 GMT</pubDate></item></channel></rss>