printer: Ensure callbacks don't run out of order #96
This commit is contained in:
parent
e1f45b3c1a
commit
f04b14c813
@ -1,5 +1,11 @@
|
|||||||
|
import gi
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gdk, GLib
|
||||||
|
from ks_includes.KlippyGcodes import KlippyGcodes
|
||||||
|
|
||||||
|
|
||||||
class Printer:
|
class Printer:
|
||||||
state_callbacks = {
|
state_callbacks = {
|
||||||
"disconnected": None,
|
"disconnected": None,
|
||||||
@ -122,8 +128,11 @@ class Printer:
|
|||||||
logging.debug("Changing state from '%s' to '%s'" % (self.state, state))
|
logging.debug("Changing state from '%s' to '%s'" % (self.state, state))
|
||||||
self.state = state
|
self.state = state
|
||||||
if self.state_callbacks[state] != None:
|
if self.state_callbacks[state] != None:
|
||||||
logging.debug("Running callback for state: %s" % state)
|
logging.debug("Adding callback for state: %s" % state)
|
||||||
self.state_callbacks[state]()
|
Gdk.threads_add_idle(
|
||||||
|
GLib.PRIORITY_HIGH_IDLE,
|
||||||
|
self.state_callbacks[state]
|
||||||
|
)
|
||||||
|
|
||||||
def configure_power_devices(self, data):
|
def configure_power_devices(self, data):
|
||||||
self.power_devices = {}
|
self.power_devices = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user