import turtle wn = turtle.Screen() tess = turtle.Turtle() tess.shape("circle") tess.color("darkgreen") # We keep track of "nested event depths" for tess. # Her drawing on the screen is smooth, but crashes soon. tess_depth = 0 hightide = 0 def tess_handler(x,y): global tess_depth, hightide tess_depth += 1 if tess_depth > hightide: hightide = tess_depth print(hightide) tess.goto(x, y) tess_depth -= 1 tess.ondrag(tess_handler) # We keep track of if the handler is busy for alex, and # queue events if the previous event has not completed. # You can see the lag here, but it doesn't crash the system! alex = turtle.Turtle(); alex.color("purple") alex.shape("turtle") alex.forward(20) alex_handler_busy = False alex_queued_events = [] def alex_handler(x,y): global alex_handler_busy if alex_handler_busy: alex_queued_events.append((x, y)) return alex_handler_busy = True alex.goto(x, y) # Flush extra events out of Alex's queue while len(alex_queued_events) > 0: (x,y) = alex_queued_events.pop(0) alex.goto(x,y) alex_handler_busy = False alex.ondrag(alex_handler) wn.mainloop()