moonraker: refactor klipper initialization
The `send_event()` method now returns a future that can be awaited until all callbacks are complete. All events emitted during Klipper init are now awaited, and a Lock is used to prevent re-entry. This resolves potential timing issues with commands sent during the init sequence. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
committed by
Eric Callahan
parent
c2bf9bf551
commit
76731b673b
@@ -108,9 +108,11 @@ class KlippyAPI(Subscribable):
|
||||
# Escape existing double quotes in the file name
|
||||
filename = filename.replace("\"", "\\\"")
|
||||
script = f'SDCARD_PRINT_FILE FILENAME="{filename}"'
|
||||
await self.server.wait_connection_initialized()
|
||||
return await self.run_gcode(script)
|
||||
|
||||
async def do_restart(self, gc: str) -> str:
|
||||
await self.server.wait_connection_initialized()
|
||||
try:
|
||||
result = await self.run_gcode(gc)
|
||||
except self.server.error as e:
|
||||
|
Reference in New Issue
Block a user