Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximum recursion depth exceeded while calling a Python object #94

Open
jiatinglu99 opened this issue Oct 6, 2022 · 8 comments
Open
Labels
enhancement New feature or request

Comments

@jiatinglu99
Copy link

jiatinglu99 commented Oct 6, 2022

Hi,

I'm getting printer shutdown upon runtime exception, the LED effect would run for a few seconds then cause an exception in klippy and shutdown the printer.

Here is the klippy log:

Stats 47029.1: gcodein=0  mcu: mcu_awake=0.284 mcu_task_avg=0.000155 mcu_task_stddev=0.000000 bytes_write=223096 bytes_read=39756 bytes_retransmit=1233 bytes_invalid=0 send_seq=5317 receive_seq=5309 retransmit_seq=5316 srtt=0.001 rttvar=0.001 rto=0.400 ready_bytes=0 stalled_bytes=3 freq=180002231 EBBCan: mcu_awake=0.001 mcu_task_avg=0.000013 mcu_task_stddev=0.000013 bytes_write=1362 bytes_read=6241 bytes_retransmit=48 bytes_invalid=0 send_seq=161 receive_seq=159 retransmit_seq=161 srtt=0.002 rttvar=0.000 rto=1.600 ready_bytes=0 stalled_bytes=2 freq=48000141 adj=47999521 host: mcu_awake=0.001 mcu_task_avg=0.000010 mcu_task_stddev=0.000014 bytes_write=1024 bytes_read=5055 bytes_retransmit=0 bytes_invalid=0 send_seq=145 receive_seq=145 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=49999593 adj=49999062 Octopus_Pro_446: temp=27.4 Raspberry_Pi: temp=52.1  heater_bed: target=0 temp=24.2 pwm=0.000 sysload=0.47 cputime=9.464 memavail=1383772 print_time=23.723 buffer_time=0.000 print_stall=0 extruder: target=0 temp=24.2 pwm=0.000
Unhandled exception during run
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/klippy.py", line 217, in run
    self.reactor.run()
  File "/home/pi/klipper/klippy/reactor.py", line 292, in run
    g_next.switch()
  File "/home/pi/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
  File "/home/pi/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
  File "/home/pi/klipper/klippy/extras/led_effect.py", line 227, in _getFrames
    chain.led_helper.update_func(chain.led_helper.led_state, None)
  File "/home/pi/klipper/klippy/extras/neopixel.py", line 107, in update_leds
    self.printer.get_reactor().register_callback(reactor_bgfunc)
  File "/home/pi/klipper/klippy/reactor.py", line 169, in register_callback
    rcb = ReactorCallback(self, callback, waketime)
  File "/home/pi/klipper/klippy/reactor.py", line 43, in __init__
    self.timer = reactor.register_timer(self.invoke, waketime)
  File "/home/pi/klipper/klippy/reactor.py", line 124, in register_timer
    timer_handler = ReactorTimer(callback, waketime)
RuntimeError: maximum recursion depth exceeded while calling a Python object
Transition to shutdown state: Unhandled exception during run
Dumping gcode input 0 blocks
Dumping 20 requests for client 3044643944

It seems like too many recursion in led_effect.py and neopixel.py?

Here is my LED effect config just in case:

# pin: printer_neopixel_pin
# chain_count: 72
# color_order: GRB

# [output_pin led_relay]
# pin: host:gpiochip0/gpio20
# value: 1
# shutdown_value: 0

[led_effect panel_idle]
autostart: true
frame_rate: 24
leds:
    neopixel:printer_led
layers:
    gradient 0.2 1 top (1.0, 0.0, 0.0),(0.0, 1.0, 0.0),(0.0, 0.0, 1.0)

Moonraker.log:

2022-10-06 09:22:33,464 [proc_stats.py:_handle_shutdown()] - Throttled Flags: 
2022-10-06 09:22:33,705 [klippy_connection.py:_on_connection_closed()] - Klippy Connection Removed

One note is that I use a relay to turn on PSUs for LED and OctopusPro, so led_effect may be running even tho the two devices aren't powered.

Any help is appreciated.

@julianschill
Copy link
Owner

I experience this problem, when trying to use too many LEDs. But 72 should actually be fine. I will look into this. On which host is running klipper? A raspberry pi?

@jiatinglu99
Copy link
Author

yes I'm running on raspberry pi 4. This actually only started happening after a recent update of everything(including led_effect, klipper, moonraker, os-packages). I had to change gradient numbers to get the same effect. Back in July, it was working perfectly.

@julianschill julianschill added the enhancement New feature or request label Oct 6, 2022
@julianschill
Copy link
Owner

I reworked the gradient effect to be smoother, but it also takes more resources. You can try reducing the framerate to compensate.

@jiatinglu99
Copy link
Author

lowering the framerate did fix the issue for now. Thanks

@allenrowand
Copy link

Having this issue as well, specifically while running a comet effect during nozzle scrubbing. This is on 12 LEDs across two chains. I'll try reducing the framerate, happy to provide any info that could help. Thanks!

@julianschill
Copy link
Owner

@jiatinglu99 and @allenrowand which board do you use how is it connected to your Pi? USB, UART or CANBUS?

@allenrowand
Copy link

I have one chain of two LEDs on an Octopus connected via USB, another chain of ten on a CAN toolhead board. I think part of my problem is that I am calling two effects too close together and the system is trying to run them simultaneously- reducing the framerate on the effect that I thought was causing the exception didn't help. I have a couple prints to finish today but I will adjust my print start script, see if that fixes the problem and report back.

@intensivecarebear80
Copy link

intensivecarebear80 commented Jun 13, 2023

I might be a little late to the party but i found a simple solution to this problem as i was facing it myself. I started by removing all my Neopixel macros as they were obviously causing the issue. Then I re-added each one of my macros until i found the culprit causing the crash, which happened to be 2 effects running at the same time, then instead of messing with the framerate or anything, i simply added a G4 P500 command between the macros that were trying to be run at the same time and hey presto, problem fixed 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants