• Luxi

    When I try to run this script and I have a print action in the update function it crashes after ~20 seconds of normal functioning.
    When I remove the print action it doesn’t crash but without a print it is really hard to do debugging.

    Sorry for very messy code

    from scene import *
    #import sound
    import random
    import math
    import Funcs
    import logging
    #import sleep
    A = Action
    
    class MyScene (Scene):
        
        def draw(self):
            pass
        def setup(self):
            
            
            self.view.update_interval = 1
            
            
    
            
            #print(get_screen_size())
            self.squares = {}
            self.states_all = {}
            self.square_number = 0      
            self.x,self.y = 0,0
            self.x_max_numbers = []
            self.all_numbers = []
            
            while self.y < (get_screen_size()[1] - 400):
                self.square = SpriteNode('shp:Circle')
                self.square.color = '#000000'
                self.square.size = 100,100  
                
                self.square.position = self.x,self.y
                self.add_child(self.square)
                
                self.x += 100
                if self.x > get_screen_size()[0] - 400:
                    self.x_max_numbers.append(self.x)
                    self.x = 0
                    self.y += 100
                
                self.squares.update({self.square_number:self.square})
                
                self.states_all.update({str(self.square):0})
                #lol#
                self.all_numbers.append(self.square_number)
                self.square_number += 1
                
                
                
            self.x_max = max(self.x_max_numbers)
            
            self.mesh = {}
            for num in range(self.square_number):
                
                meshes = Funcs.finding(num,int(self.x_max / 100),self.square_number - 1,self.y)
                self.mesh.update({num:meshes})
            #exit(self.mesh)
            
            
            
            #print(self.square.children)
            
        
            
            self.fram = 0   
            
            self.pause_mode = False
            self.pause = SpriteNode('iow:ios7_star_256')
            self.pause.scale = 0.5
            self.pause.position = (get_screen_size()[0] / 2), 800 #(get_screen_size()[1] - self.pause.size[1])
            self.add_child(self.pause)
            print(self.all_numbers)
            print('serup fertig')
            
            
            
            
            
            
            
    #--------------------------------------------------------------------------------------------------------------------
        def update(self):
            #for touch in self.touches.values():
                
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            #self.fram += 1
            #print(self.fram)
            #print('update')
            squares = self.squares
            mesh = self.mesh
            square_number = self.square_number
            states_all = self.states_all
            #print(6)
            all_numbers = self.all_numbers
            
            for curent_cell in self.all_numbers:
                #print(curent_cell)
                #print(states_all)
                if self.pause_mode == False:
                    #print(6)
                    curent_cell_obj = self.squares[curent_cell]
                    nachbarn = self.mesh[curent_cell]
                    Anzahl_lebend = 0
                    Anzahl_Tot = 0
                    
                    for nachbar in nachbarn:
                        logging.log(10,'hi')
                        state_square = self.squares[nachbar]
                        #print(state_square)
                        state_now = self.states_all[str(state_square)]
                        
                        if state_now == 1:
                            Anzahl_lebend += 1
                        if state_now == 0:
                            Anzahl_Tot += 1
                    alive = True
                    
                    if Anzahl_lebend < 2 or Anzahl_lebend > 3:
                        alive = False
                    if Anzahl_lebend == 2 or Anzahl_lebend == 3:
                        alive = True
                    
                #   if alive == True:
                    #   self.states_all[str(curent_cell_obj)]   = 1
                        #curent_cell_obj.color = '#ffffff'
                    #else:
                        #self.states_all[str(curent_cell_obj)]  = 0
                        #curent_cell_obj.color = '#000000'
                    #print(Anzahl_lebend)
                    #print(Anzahl_Tot)
                    print(Anzahl_lebend)
            #Scene.setup(self)
        
        
            
        def touch_began(self, touch):
            for obj in self.squares.values():
                    print('touched')
                    if touch.location in obj.bbox:
                        #print(obj.color)
                        if obj.color != (0.0, 0.0, 0.0, 1.0):
                            obj.color = '#000000'
                            self.states_all[obj] = 0
                        else:
                            #print('war nicht ')
                            obj.color = '#ffffff'
                            self.states_all[obj] = 1
            if touch.location in self.pause.bbox:
                if self.pause_mode == False:
                    self.pause_mode = True
                else:
                    self.pause_mode = False
                        
        def touch_moved(self, touch):
            pass
        
        def touch_ended(self, touch):
            pass
    
    
    run(MyScene(), show_fps=True) ```

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!