stealthmonkey99 / OctoPrint-PWMBuzzer

M300 gcode handler (PWM buzzer via GPIO) for OctoPrint
6 stars 1 forks source link

fix #13: wait for tone queue to play out on shutdown #14

Closed stealthmonkey99 closed 2 years ago

stealthmonkey99 commented 2 years ago

Description

When testing #11 I realized that setting a tune on Shutdown resulted in only the first note being played before the rest was cut off. Since playback was moved to a non-blocking thread, the tune no longer blocks on shutdown. While we do NOT want to introduce long-running operations on shutdown, this change does wait up to 3 seconds for a tune to finish playing if one is triggered on the Shutdown event. If the tune is longer than 3 seconds, it will be truncated at that point as the system continues to shut down and terminate the ToneQueue's worker thread.

Test Plan

These changes can be tested by installing the plugin from: https://github.com/stealthmonkey99/OctoPrint-PWMBuzzer/archive/block-shutdown-tune.zip