RuntimeError: pystack exhausted

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
neveregret
 
Posts: 8
Joined: Mon Sep 27, 2021 10:28 am

RuntimeError: pystack exhausted

Post by neveregret »

Hello everyone, I am trying to make a project with W5500. I want to understand If I have internet or not so I wrote this code:

Code: Select all

response = None
while not response:
    try:
        eth = WIZNET5K(spi_bus,cs,dhcp_timeout=3)
        requests.set_socket(socket, eth)
        TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
        response = requests.get(TEXT_URL)
    except AssertionError as error:
        print("Checking")
        
print("Text Response: ", response.text)
response.close()
response = None
 while True:
            try:
                   JSON_URL = ("example.com")
                    r=requests.get(JSON_URL)
                    response = r.json()
                    default = response["word"]
                    defaultRead=default
                    print(r.json())
                    r.close()
            except AssertionError as error:      

When I run the code, It gives pystack error on this line

Code: Select all

 r=requests.get(JSON_URL)
. I found this : viewtopic.php?f=60&t=179979&p=875852&hi ... ed#p875852 and this https://github.com/adafruit/circuitpython/issues/3208 I couldn't find more. I am not using recursion.This code is working like this but when the codes increase (300 line) it gives this error. What should ı do?
The other question is, which mpconfig.h should I change?
https://github.com/adafruit/circuitpyth ... aspberrypi this or
this https://github.com/adafruit/circuitpyth ... ry_pi_pico
I am using raspberry pi pico. And are these defines enough ?

Code: Select all

 #ifndef CIRCUITPY_PYSTACK_SIZE
-#define CIRCUITPY_PYSTACK_SIZE 1024
+#define CIRCUITPY_PYSTACK_SIZE 2048
 #endif
 
 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"

User avatar
tannewt
 
Posts: 3298
Joined: Thu Oct 06, 2016 8:48 pm

Re: RuntimeError: pystack exhausted

Post by tannewt »

If it is defined in the board file, it will override the port setting because of the `ifndef` in what you showed. Either one will confirm that raising the value fixes your issue. I'm open to doing it for all boards so adding it the port would be best I think. (Please make a PR for it too.)

User avatar
neveregret
 
Posts: 8
Joined: Mon Sep 27, 2021 10:28 am

Re: RuntimeError: pystack exhausted

Post by neveregret »

tannewt wrote:If it is defined in the board file, it will override the port setting because of the `ifndef` in what you showed. Either one will confirm that raising the value fixes your issue. I'm open to doing it for all boards so adding it the port would be best I think. (Please make a PR for it too.)
Okay, thank you. https://github.com/adafruit/circuitpython/pull/5677 I opened PR but I don't know if it is the right place.

User avatar
tannewt
 
Posts: 3298
Joined: Thu Oct 06, 2016 8:48 pm

Re: RuntimeError: pystack exhausted

Post by tannewt »

Thanks! Someone will follow up there.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”