rutime error after many time

Asked by Bastien Litzenburger

Hi,

I have a problem with my sikuli's code
After many time he stop with this log :

[error] script [ CASINO ] stopped with error in line 59
[error] RuntimeError ( maximum recursion depth exceeded (Java StackOverflowError) )
[error] --- Traceback --- error source first
line: module ( function ) statement
34: main ( No ) if exists(Pattern("1699134039634.png").similar(0.87)):

I tried with this

import sys
sys.setrecursionlimit(10000)

But same bug

nobody can help me ?

there is my code
thanks :)

import sys
sys.setrecursionlimit(10000)
def Ok():
    if exists("1699199849041.png"):
        wait(1)
        type(Key.WIN)
        wait(1)
        click(Region(641,737,35,19))
        wait(1)
        click(Region(799,65,47,13))
        wait(2)
        dragDrop(Region(935,38,100,95),Region(977,75,81,57))
        wait(1)
        click(Region(1092,60,34,23))
        wait(1)
        click(Region(597,731,28,35))
        wait(1)
        click(Region(40,224,27,14))
        wait(1)
        click(Region(16,66,32,43))
        click(Region(1331,684,16,17))
        click(Region(1243,10,19,12))
        click(Region(542,734,27,29))
        No()

    else:
        wait(1)
        No()

def No():
    if exists(Pattern("1699134039634.png").similar(0.87)):
        type(Key.WIN)
        click("1699134401676.png")
        wait(1)
        click(Region(28,226,24,12))
        click(Region(261,170,33,12))
        type("R")
        wait(1)
        type(Key.WIN)
        wait(1)
        click(Region(547,734,27,28))
        wait(1)
        type(Key.ESC)
        wait(1)
        click("1699134163372.png")
        wait(10)
        click("1699134213655.png")
        wait(1)
        click(Pattern("1699134243208.png").similar(0.80))
        wait(1)
        Ok()
    else :
        Ok()

for step in range (10000):
    Ok()

Question information

Language:
French Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

The problem is caused by your program logic.

You start Ok() which calls the function No() which in turn branches into Ok() and so on (each of them without ending the previous subroutine). Sooner or later this exceeds whatever limit there is.

You have to restructure your program.

The following might work:

(init part)
for step in range (10000):
    if exists("1699199849041.png"):
        (clicks and waits)
    else:
        wait(1)
    if exists(Pattern("1699134039634.png").similar(0.87)):
        (clicks and waits)

Can you help with this problem?

Provide an answer of your own, or ask Bastien Litzenburger for more information if necessary.

To post a message you must log in.