<?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[maximum recursion depth]]></title><description><![CDATA[<p dir="auto">I know this has been asked elsewhere, but the answer I require hasn't appeared.</p>
<p dir="auto">My code, which uses threads but has no (intentionally) recursive calls, is throwing &quot;maximum recursion depth exceeded&quot; exceptions.</p>
<p dir="auto">Using this test :</p>
<pre><code>def recursion_check(count):
    ## https://forum.micropython.org/viewtopic.php?t=3091
    try:
        return recursion_check(count+1)
    except:
        return count
</code></pre>
<p dir="auto">I can see that without threads, the recursion depth is 49 (or more likely 50).</p>
<p dir="auto">When run inside a thread, the above code returns a paltry 10, regardless of the number of threads or the stack size, which I've tried resetting with <code> _thread.stack_size(16 * 1024)</code> (my board is an ESP32 with additional 64Mbit PSRAM).</p>
<p dir="auto">I think this exception is being thrown because a call stack limit is being hit, and has nothing to do with recursion.   My code paths are predictable , with few differences between ones that succeed and ones that don't.</p>
<p dir="auto">On this basis, I'd like to increase the 'call stack limit, which would seem to be hard coded somewhere in the MP source.  I've searched in the usual places, but come up empty handed.</p>
<p dir="auto">Could someone please point the way to this mod?</p>
<p dir="auto">Without too many suggestions along the lines of converting function calls to loops or not using threads, thanks.  :-)</p>
]]></description><link>https://forum.pycom.io/topic/5960/maximum-recursion-depth</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 11:25:06 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/5960.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 May 2020 06:43:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to maximum recursion depth on Tue, 12 May 2020 06:44:08 GMT]]></title><description><![CDATA[<p dir="auto">I know this has been asked elsewhere, but the answer I require hasn't appeared.</p>
<p dir="auto">My code, which uses threads but has no (intentionally) recursive calls, is throwing &quot;maximum recursion depth exceeded&quot; exceptions.</p>
<p dir="auto">Using this test :</p>
<pre><code>def recursion_check(count):
    ## https://forum.micropython.org/viewtopic.php?t=3091
    try:
        return recursion_check(count+1)
    except:
        return count
</code></pre>
<p dir="auto">I can see that without threads, the recursion depth is 49 (or more likely 50).</p>
<p dir="auto">When run inside a thread, the above code returns a paltry 10, regardless of the number of threads or the stack size, which I've tried resetting with <code> _thread.stack_size(16 * 1024)</code> (my board is an ESP32 with additional 64Mbit PSRAM).</p>
<p dir="auto">I think this exception is being thrown because a call stack limit is being hit, and has nothing to do with recursion.   My code paths are predictable , with few differences between ones that succeed and ones that don't.</p>
<p dir="auto">On this basis, I'd like to increase the 'call stack limit, which would seem to be hard coded somewhere in the MP source.  I've searched in the usual places, but come up empty handed.</p>
<p dir="auto">Could someone please point the way to this mod?</p>
<p dir="auto">Without too many suggestions along the lines of converting function calls to loops or not using threads, thanks.  :-)</p>
]]></description><link>https://forum.pycom.io/post/32675</link><guid isPermaLink="true">https://forum.pycom.io/post/32675</guid><dc:creator><![CDATA[bitrat]]></dc:creator><pubDate>Tue, 12 May 2020 06:44:08 GMT</pubDate></item></channel></rss>