Repository navigation
Conversation
|
A Is there a piece of code in Klipper that actually reaches this state, or a log that shows the problem? -Maksim |
Ensure ReactorCompletion.wait() removes its registered greenlet even if reactor.pause() raises an exception. Otherwise a subsequent complete() may attempt to wake a stale waiter. Signed-off-by: Sergei Rozhkov <zmod@zmod.link> Co-authored-by: djvalic <djvalic@users.noreply.github.com>
f0e6dc2 to
083fad0
Compare
|
This issue was observed on a real AD5X running Kiln OS after M112 and restart.
The subsequent Original patch and failure description by djvalic. The fix prevents this secondary exception without suppressing the original |
|
I guess the right question is, can you provide an example config that will reproduce the issue on the mainline? Basically: Because if there is a valid configuration that can trigger pause protection, it should be fixed. Otherwise, I've tried to reproduce something similar: diff --git a/klippy/extras/save_variables.py b/klippy/extras/save_variables.py
index b6d6ac619..b797d260d 100644
--- a/klippy/extras/save_variables.py
+++ b/klippy/extras/save_variables.py
@@ -22,6 +22,9 @@ class SaveVariables:
gcode = self.printer.lookup_object('gcode')
gcode.register_command('SAVE_VARIABLE', self.cmd_SAVE_VARIABLE,
desc=self.cmd_SAVE_VARIABLE_help)
+ self.printer.register_event_handler("klippy:ready", self._handle_ready)
+ def _handle_ready(self):
+ self.printer.get_reactor().pause(.0)
def loadVariables(self):
allvars = {}
varfile = configparser.ConfigParser()So, it seems to me that everything behaves as expected; the printer goes to shutdown: So, even if I understand what the change does, I'm not sure how it should happen. Regards, |
The difference is that + self.printer.register_event_handler("klippy:ready", self._handle_ready)
+ def _handle_ready(self):
+ self.executor.submit(lambda: None)In the Still, nothing in mainline calls SAVE_VARIABLE from -Maksim |
If
reactor.pause()raises an exception inReactorCompletion.wait(), the waiting greenlet is not removed from the completion's waiter list.A subsequent call to
complete()may therefore attempt to wake a stale waiter.Use a
try/finallyblock to ensure the waiter is removed even when an exception occurs.Normal completion and timeout behavior remain unchanged. No configuration or API changes are required.