diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2025-05-14 18:47:36 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2025-06-04 13:46:28 -0400 |
commit | d120a313b75a41e6d3ae1f53cda9dbd6e1d31615 (patch) | |
tree | 2af415dd787f570c7294cfdc0413c765a7f06dc3 | |
parent | 4d4b9684a53fa7e776914b222cdab21f870dad76 (diff) | |
download | kutter-d120a313b75a41e6d3ae1f53cda9dbd6e1d31615.tar.gz kutter-d120a313b75a41e6d3ae1f53cda9dbd6e1d31615.tar.xz kutter-d120a313b75a41e6d3ae1f53cda9dbd6e1d31615.zip |
docs: Note 'config' object shouldn't be accessed after initial load
Update Code_Overview.md to note that the config object should not be
stored after the "config loading phase".
Remove a few inadvertent cases where a 'config' object was stored
in module member variables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | docs/Code_Overview.md | 5 | ||||
-rw-r--r-- | klippy/extras/ads1x1x.py | 1 | ||||
-rw-r--r-- | klippy/extras/screws_tilt_adjust.py | 3 | ||||
-rw-r--r-- | klippy/extras/z_thermal_adjust.py | 1 |
4 files changed, 6 insertions, 4 deletions
diff --git a/docs/Code_Overview.md b/docs/Code_Overview.md index 9ccaa60b..fd0e90a3 100644 --- a/docs/Code_Overview.md +++ b/docs/Code_Overview.md @@ -286,6 +286,11 @@ The following may also be useful: during the `load_config()` or "connect event" phases. Use either `raise config.error("my error")` or `raise printer.config_error("my error")` to report the error. +* Do not store a reference to the `config` object in a class member + variable (nor in any similar location that may persist past initial + module loading). The `config` object is a reference to a "config + loading phase" class and it is not valid to invoke its methods after + the "config loading phase" has completed. * Use the "pins" module to configure a pin on a micro-controller. This is typically done with something similar to `printer.lookup_object("pins").setup_pin("pwm", diff --git a/klippy/extras/ads1x1x.py b/klippy/extras/ads1x1x.py index 1d72996f..10cd01f9 100644 --- a/klippy/extras/ads1x1x.py +++ b/klippy/extras/ads1x1x.py @@ -321,7 +321,6 @@ class ADS1X1X_pin: def __init__(self, chip, config): self.mcu = chip.mcu self.chip = chip - self.config = config self.invalid_count = 0 diff --git a/klippy/extras/screws_tilt_adjust.py b/klippy/extras/screws_tilt_adjust.py index fec54185..b988c7ce 100644 --- a/klippy/extras/screws_tilt_adjust.py +++ b/klippy/extras/screws_tilt_adjust.py @@ -9,7 +9,6 @@ from . import probe class ScrewsTiltAdjust: def __init__(self, config): - self.config = config self.printer = config.get_printer() self.screws = [] self.results = {} @@ -33,7 +32,7 @@ class ScrewsTiltAdjust: default='CW-M3') # Initialize ProbePointsHelper points = [coord for coord, name in self.screws] - self.probe_helper = probe.ProbePointsHelper(self.config, + self.probe_helper = probe.ProbePointsHelper(config, self.probe_finalize, default_points=points) self.probe_helper.minimum_points(3) diff --git a/klippy/extras/z_thermal_adjust.py b/klippy/extras/z_thermal_adjust.py index 4cf3a669..a3a5997e 100644 --- a/klippy/extras/z_thermal_adjust.py +++ b/klippy/extras/z_thermal_adjust.py @@ -16,7 +16,6 @@ class ZThermalAdjuster: self.printer = config.get_printer() self.gcode = self.printer.lookup_object('gcode') self.lock = threading.Lock() - self.config = config # Get config parameters, convert to SI units where necessary self.temp_coeff = config.getfloat('temp_coeff', minval=-1, maxval=1, |