Fatal Python error: Cannot recover from stack overflow
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
def loop():
s = "ss"
while s == "ss":
error = False
try:
driver.find_element_by_xpath("/html/body/div[4]/div[1]/div[3]/div/div[2]/div/button").click()
except:
print(f'''{Fore.RED}[-] The captcha is unsolved!{Fore.RESET}''')
sleep(8)
driver.refresh()
error = True
if not error:
s = "notss"
try:
sleep(2)
driver.find_element_by_xpath('//*[@id="sid2"]/div/form/div/input').send_keys(vidUrl)
sleep(1)
driver.find_element_by_xpath('//*[@id="sid2"]/div/form/div/div/button').click()
sleep(5)
driver.find_element_by_xpath('//*[@id="c2VuZE9nb2xsb3dlcnNfdGlrdG9r"]/div[1]/div/form/button').click()
sleep(6)
hearts = driver.find_element_by_xpath('//*[@id="c2VuZE9nb2xsb3dlcnNfdGlrdG9r"]/span').text.split()
int(hearts[0])
print(f'''{Fore.GREEN}[+] Hearts sent!{Fore.RESET}''')
sleep(5)
driver.refresh()
sleep(10)
loop()
except:
print(f'''{Fore.RED}[-] An error occured, Retrying..{Fore.RESET}''')
driver.refresh()
sleep(5)
loop()
Description
I believe its because i have used loop a but i am unsure how to stop it from causing this error
Operating System
Windows
Operating System Details
21H2
FastAPI Version
0.71.0
Python Version
3.9.0
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Fatal Python error: Cannot recover from stack overflow
I have a function that for each line of data (data have around 2'000'000 rows) do something and then recall the same function...
Read more >Fatal Python error: Cannot recover from stack overflow
The "Fatal Python error: Cannot recover from stack overflow" occurs when Python already raised a RecursionError (RuntimeError on Python < 3.5) ...
Read more >Fatal Python error: Cannot recover from stack overflow.
Sometimes it happens immediately after trying to attach, sometimes the operation is successful, and it happens after a few seconds of doing some...
Read more >Fatal Python error: cannot recover from stack overflow - Odoo
I have created a custom module, made some changes, added a transient model and added a qweb report and when upgrading I cannot...
Read more >Cannot recover from stack overflow error while parsing using ...
...implies that the recursion limit in your program logic exceeds the maximum depth of the Python interpreter stack. Deep Dive. You are getting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the record, when raising an issue, people tend to appreciate a minimal reproducible example.
I understand you may be new to programming, so let me give you an example of how I would have gone around to troubleshooting this issue (which is by no mean the one true way, merely an example):
Step 1: put the relevant code in a separate
.py
file and run itThis would have highlighted that your example is missing some context about:
driver
;vidUrl
;Fore
;sleep
.From the way you use it, I understand that
driver
could be an instance ofselenium
’sWebDriver
,Fore
comes fromcolorama
,sleep
istime.sleep
from python’s standard library, andvidUrl
is probably a string containing a URL.Make sure that the snippet runs by itself and that it exhibits the issue you are investigating. On linux, it would mean running:
Where
reproducer.py
is the name of the file I put the code in.If you are using an IDE, refer to its documentation on how to run standalone python scripts.
Step 2: remove as much code as you can
It is best to go step by step about it:
In order, I think I would have removed:
sleep
: to make the code faster to run;driver
: to eliminate the dependency onselenium
;Fore
: to eliminate the dependency oncolorama
.That would have gotten me something like:
Then, if it hadn’t been clear by now what the issue is, I would have removed either the
while
look of thetry
/except
block.Only the version with the
try
/except
block would have kept showing the issue, so that is the one I would have kept. We are now down to:Which, thinking about it, is equivalent to:
Somewhere along the way, you might have noticed that the error message changed and is now:
It could mean that I removed too many lines and am now getting into a totally unrelated issue, but actually, if you read about it, you will find that the two errors are related and this new error message gives you more information about the issue’s root cause than the old one.
Step 3: Search online for the error message
Use your favorite search engine to research: “RecursionError: maximum recursion depth exceeded”.
If you don’t find any explanation about it that fits your use case or you don’t understand the answers, only then consider asking a question on stackoverflow.com (or the relevant github project, although in this case stackoverflow.com is the way I would go myself).
Read about how to ask a good question if you can, it’ll help you get the best answer.
It seems from your code that you are not using FastAPI, in that case this wouldn’t be the place to ask.
Funnily enough, the right place would be on StackOverflow (the same name as your error 😅)