feat(analyse): power-saving mode for Stockfish thinking
public
feat(analyse): power-saving mode for Stockfish thinking Thinking along ran 8 threads at full load for up to 30 s per move, costing laptops roughly 15-20 % battery per game. New "Analyse" preferences page sets threads, max depth and max time for two profiles: - Normal: min(8, cpus/2) threads, depth 30, 30 s - Energiesparen: 2 threads, depth 18, 10 s Mode Automatisch/Immer/Nie; automatic saves on battery (psutil, optional, Linux/Windows/macOS) or when the system power profile is power-saver (Gio.PowerProfileMonitor). Checked per think job, so plugging in takes effect on the next move. Depth floor 18 keeps the Stockfish hint final. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | c6390964f0a9994752737306957102eb8aa1a841 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | 5165fdca2196 |
| Children | c6a58c80691f |
| Pushlog | by timo via ssh by timo via ssh |
modified README.md +6 −1
| @@ -19,6 +19,10 @@ Schlichtes GNOME-Schachprogramm (Python, | ||
| 19 | 19 | - **Zugbewertung:** Stockfish denkt mit, während du überlegst (Top-3-Züge, live |
| 20 | 20 | immer tiefer); andere Züge werden nur bei Bedarf einzeln nachgerechnet. |
| 21 | 21 | Nur auffällige Züge bekommen ein Zeichen an der Figur: `!!` `!` `?!` `?` `??`. |
| 22 | + Wie lange, steht unter Einstellungen → Analyse: Threads, maximale Tiefe und Rechenzeit, je | |
| 23 | + für „Normal“ (halb so viele Threads wie der Rechner hat, höchstens 8; Tiefe 30 oder 30 s) und | |
| 24 | + „Energiesparen“ (2 Threads, Tiefe 18 oder 10 s). Automatisch gespart wird auf Akku oder wenn | |
| 25 | + das System auf „Energiesparen“ steht; danach schläft das Programm (0 % CPU). | |
| 22 | 26 | - **Zugliste** (Taste `A`): ein Halbzug pro Zeile, dahinter ein Weiß/Schwarz-Balken |
| 23 | 27 | mit der Gewinnchance – untereinander ergibt das den Verlauf der Partie. Während |
| 24 | 28 | der Partie zugeklappt, am Ende öffnet sie sich. Zeile anklicken öffnet dort das |
| @@ -101,7 +105,8 @@ Schlichtes GNOME-Schachprogramm (Python, | ||
| 101 | 105 | |
| 102 | 106 | Abhängigkeiten: `python-gobject`, `libadwaita`, `librsvg`, `python-chess`, |
| 103 | 107 | `stockfish`, `python-requests`, `python-keyring`, und für Maia-3 `onnxruntime-cpu` (oder eine |
| 104 | -andere onnxruntime-Variante), `python-numpy`. | |
| 108 | +andere onnxruntime-Variante), `python-numpy`. Optional `python-psutil`: erkennt den Akkubetrieb | |
| 109 | +(Linux, Windows, macOS) für den Energiesparmodus; ohne gilt der Rechner als am Netz. | |
| 105 | 110 | |
| 106 | 111 | Maia-3 läuft über ONNX Runtime statt PyTorch (`schach/maia_onnx.py`). Das Modell (ONNX-Export |
| 107 | 112 | von Maia3-79M mit Zughistorie, `bqrio/maia3-onnx`, 156 MB, per Prüfsumme festgelegt) lädt |
modified schach/annotate.py +7 −4
| @@ -31,7 +31,7 @@ HINT_MIN_DEPTH = 8 | ||
| 31 | 31 | HINT_DEPTH = 18 |
| 32 | 32 | |
| 33 | 33 | TOP_LINES = 3 # so viele beste Züge rechnet Stockfish live mit |
| 34 | -THINK_LIMIT = chess.engine.Limit(depth=30, time=30) # Obergrenze fürs Mitdenken | |
| 34 | +THINK_LIMIT = chess.engine.Limit(depth=30, time=30) # Obergrenze fürs Mitdenken (Standard, s. energy.py) | |
| 35 | 35 | MIN_DEPTH = 14 # ab hier gilt eine Momentaufnahme als belastbar |
| 36 | 36 | QUICK_LIMIT = chess.engine.Limit(depth=MIN_DEPTH) # falls schon vor dem Start gezogen wurde |
| 37 | 37 | EXTRA_LIMIT = chess.engine.Limit(depth=MIN_DEPTH) # einzelne Züge nachrechnen |
| @@ -133,13 +133,14 @@ class Thinking: | ||
| 133 | 133 | self._analysis.stop() |
| 134 | 134 | |
| 135 | 135 | |
| 136 | -def think_job(board, thinking, on_snapshot, on_hint=None): | |
| 136 | +def think_job(board, thinking, on_snapshot, on_hint=None, limit=THINK_LIMIT, threads=None): | |
| 137 | 137 | """Job-Fabrik: Stockfish denkt mit, solange der Mensch überlegt. |
| 138 | 138 | |
| 139 | 139 | Rechnet die Top-Linien live immer tiefer, bis ``thinking.stop()``. ``on_hint(zug, endgültig)`` |
| 140 | 140 | (nur wenn Stockfish der Hinweisgeber ist): ab HINT_MIN_DEPTH nach jeder Tiefe, endgültig bei |
| 141 | 141 | HINT_DEPTH oder einem eigenen Matt. ``on_snapshot``/``on_hint`` laufen im Worker-Thread; |
| 142 | - Ergebnis ist die letzte Momentaufnahme. | |
| 142 | + Ergebnis ist die letzte Momentaufnahme. ``limit`` begrenzt das Mitdenken, ``threads`` stellt | |
| 143 | + Stockfish vorher um (bleibt danach so, auch für andere Jobs auf diesem Worker). | |
| 143 | 144 | """ |
| 144 | 145 | board = board.copy() |
| 145 | 146 | |
| @@ -147,9 +148,11 @@ def think_job(board, thinking, on_snapsh | ||
| 147 | 148 | n = min(TOP_LINES, board.legal_moves.count()) |
| 148 | 149 | if n == 0: |
| 149 | 150 | return None |
| 151 | + if threads: | |
| 152 | + engine.configure({"Threads": threads}) # schickt nur, was sich geändert hat | |
| 150 | 153 | quick = thinking.stopped # schon gezogen: nur rasch die Bewertung, kein Hinweis |
| 151 | 154 | last, settled = None, on_hint is None or quick |
| 152 | - with engine.analysis(board, QUICK_LIMIT if quick else THINK_LIMIT, multipv=n) as analysis: | |
| 155 | + with engine.analysis(board, QUICK_LIMIT if quick else limit, multipv=n) as analysis: | |
| 153 | 156 | thinking.attach(analysis) |
| 154 | 157 | for info in analysis: |
| 155 | 158 | # Zeilen 1..n kommen am Ende jeder Tiefe; Zeile n = Tiefe fertig |
modified schach/app.py +4 −3
| @@ -15,7 +15,7 @@ gi.require_version("Gtk", "4.0") | ||
| 15 | 15 | gi.require_version("Adw", "1") |
| 16 | 16 | from gi.repository import Adw, Gdk, Gio, GLib, GObject, Gtk # noqa: E402 |
| 17 | 17 | |
| 18 | -from . import annotate, clipboard, lichess, notation, savegames # noqa: E402 | |
| 18 | +from . import annotate, clipboard, energy, lichess, notation, savegames # noqa: E402 | |
| 19 | 19 | from .board import BoardView, available_themes # noqa: E402 |
| 20 | 20 | from .movelist import MoveList # noqa: E402 |
| 21 | 21 | from .prefs import Preferences # noqa: E402 |
| @@ -1323,8 +1323,9 @@ class Window(OnlineMixin, PuzzleMixin, O | ||
| 1323 | 1323 | |
| 1324 | 1324 | def think(hint_from_stockfish): |
| 1325 | 1325 | # Stockfish denkt immer mit (Bewertung, Zugzeichen); den Hinweis gibt er nur als Helfer |
| 1326 | + threads, limit = energy.think_settings(self.settings) # Akku jetzt prüfen, nicht beim Start | |
| 1326 | 1327 | job = annotate.think_job(board, thinking, snapshot_from_thread, |
| 1327 | - hint_from_thread if hint_from_stockfish else None) | |
| 1328 | + hint_from_thread if hint_from_stockfish else None, limit, threads) | |
| 1328 | 1329 | self.stockfish.submit(job, on_done) |
| 1329 | 1330 | |
| 1330 | 1331 | def on_maia(moves, error): |
| @@ -2137,7 +2138,7 @@ class SchachApp(Adw.Application): | ||
| 2137 | 2138 | self.maia = EngineWorker(MAIA_CMD, on_ready=self._on_maia_ready, cwd=MAIA_CWD, |
| 2138 | 2139 | prepare=MAIA_PREPARE, on_progress=self._on_maia_progress) |
| 2139 | 2140 | self.stockfish = EngineWorker( |
| 2140 | - STOCKFISH_CMD, options={"Threads": min(8, os.cpu_count() or 2), "Hash": 256} | |
| 2141 | + STOCKFISH_CMD, options={"Threads": energy.think_settings(load_settings())[0], "Hash": 256} | |
| 2141 | 2142 | ) |
| 2142 | 2143 | token = lichess.load_token() |
| 2143 | 2144 | if token: |
added schach/energy.py +89 −0
| @@ -0,0 +1,89 @@ | ||
| 1 | +"""Wie viel Stockfish mitdenkt: normaler Modus und Energiesparmodus. | |
| 2 | + | |
| 3 | +Der Modus gilt pro Mitdenk-Rechnung (``think_settings``), ein Wechsel aufs Netzteil wirkt also beim | |
| 4 | +nächsten Zug. „Automatisch“ spart, wenn der Rechner auf Akku läuft (psutil, auf Linux, Windows und | |
| 5 | +macOS; ohne psutil gilt „am Netz“) oder das System auf „Energiesparen“ steht (GLib, nur Linux). | |
| 6 | +""" | |
| 7 | + | |
| 8 | +import os | |
| 9 | + | |
| 10 | +import chess.engine | |
| 11 | + | |
| 12 | +MODES = [("auto", "Automatisch"), ("always", "Immer"), ("never", "Nie")] | |
| 13 | +PROFILES = ("normal", "saver") | |
| 14 | + | |
| 15 | +MIN_DEPTH = 18 # darunter wird der Stockfish-Hinweis nie endgültig (annotate.HINT_DEPTH) | |
| 16 | +MAX_DEPTH = 40 | |
| 17 | +MIN_TIME, MAX_TIME = 5, 120 | |
| 18 | + | |
| 19 | + | |
| 20 | +def default_threads(): | |
| 21 | + """Ein Thread pro echtem Kern (cpu_count zählt Hyperthreads mit), höchstens 8.""" | |
| 22 | + return max(1, min(8, (os.cpu_count() or 2) // 2)) | |
| 23 | + | |
| 24 | + | |
| 25 | +def defaults(profile): | |
| 26 | + if profile == "saver": | |
| 27 | + return {"threads": 2, "depth": 18, "time": 10} | |
| 28 | + return {"threads": default_threads(), "depth": 30, "time": 30} | |
| 29 | + | |
| 30 | + | |
| 31 | +def analysis_settings(settings): | |
| 32 | + analysis = settings.get("analysis") | |
| 33 | + return analysis if isinstance(analysis, dict) else {} | |
| 34 | + | |
| 35 | + | |
| 36 | +def profile_values(settings, profile): | |
| 37 | + """Werte eines Profils: Standard, überschrieben von den Einstellungen, auf gültige Grenzen gestutzt.""" | |
| 38 | + values = defaults(profile) | |
| 39 | + stored = analysis_settings(settings).get(profile) | |
| 40 | + stored = stored if isinstance(stored, dict) else {} | |
| 41 | + for name, (low, high) in {"threads": (1, os.cpu_count() or 1), "depth": (MIN_DEPTH, MAX_DEPTH), | |
| 42 | + "time": (MIN_TIME, MAX_TIME)}.items(): | |
| 43 | + if isinstance(stored.get(name), (int, float)): | |
| 44 | + values[name] = int(min(high, max(low, stored[name]))) | |
| 45 | + return values | |
| 46 | + | |
| 47 | + | |
| 48 | +def on_battery(): | |
| 49 | + """True auf Akku, False am Netz, None wenn unbekannt (kein Akku oder kein psutil).""" | |
| 50 | + try: | |
| 51 | + import psutil | |
| 52 | + battery = psutil.sensors_battery() | |
| 53 | + except Exception: # noqa: BLE001 – ImportError, oder der Sensor ist kaputt | |
| 54 | + return None | |
| 55 | + if battery is None or battery.power_plugged is None: | |
| 56 | + return None | |
| 57 | + return not battery.power_plugged | |
| 58 | + | |
| 59 | + | |
| 60 | +def power_saver(): | |
| 61 | + """Steht das System auf „Energiesparen“ (power-profiles-daemon)? Außerhalb von Linux immer False.""" | |
| 62 | + try: | |
| 63 | + from gi.repository import Gio | |
| 64 | + return bool(Gio.PowerProfileMonitor.dup_default().get_power_saver_enabled()) | |
| 65 | + except Exception: # noqa: BLE001 | |
| 66 | + return False | |
| 67 | + | |
| 68 | + | |
| 69 | +def active_profile(settings, battery=None, saver=None): | |
| 70 | + """(Profil, Grund) – Grund ist ein kurzer Text für die Einstellungen. | |
| 71 | + | |
| 72 | + ``battery``/``saver`` nur für Tests; sonst wird das System gefragt. | |
| 73 | + """ | |
| 74 | + mode = analysis_settings(settings).get("mode", "auto") | |
| 75 | + if mode == "always": | |
| 76 | + return "saver", "immer eingeschaltet" | |
| 77 | + if mode == "never": | |
| 78 | + return "normal", "ausgeschaltet" | |
| 79 | + if (on_battery() if battery is None else battery): | |
| 80 | + return "saver", "Rechner läuft auf Akku" | |
| 81 | + if (power_saver() if saver is None else saver): | |
| 82 | + return "saver", "System steht auf Energiesparen" | |
| 83 | + return "normal", "am Netz" | |
| 84 | + | |
| 85 | + | |
| 86 | +def think_settings(settings, **probe): | |
| 87 | + """(Threads, chess.engine.Limit) für die nächste Mitdenk-Rechnung.""" | |
| 88 | + values = profile_values(settings, active_profile(settings, **probe)[0]) | |
| 89 | + return values["threads"], chess.engine.Limit(depth=values["depth"], time=values["time"]) | |
modified schach/prefs.py +65 −1
| @@ -8,7 +8,7 @@ gi.require_version("Gtk", "4.0") | ||
| 8 | 8 | gi.require_version("Adw", "1") |
| 9 | 9 | from gi.repository import Adw, Gio, GLib, Gtk # noqa: E402 |
| 10 | 10 | |
| 11 | -from . import notation, opening # noqa: E402 | |
| 11 | +from . import energy, notation, opening # noqa: E402 | |
| 12 | 12 | from .board import DEFAULT_SCHEME, SCHEMES, scheme_colors # noqa: E402 |
| 13 | 13 | from .diagram import USER_PIECES_DIR # noqa: E402 |
| 14 | 14 | |
| @@ -24,6 +24,7 @@ class Preferences(Adw.PreferencesDialog) | ||
| 24 | 24 | self.pages = { |
| 25 | 25 | "general": self._general_page(), |
| 26 | 26 | "appearance": self._appearance_page(), |
| 27 | + "analysis": self._analysis_page(), | |
| 27 | 28 | "lichess": self._lichess_page(), |
| 28 | 29 | } |
| 29 | 30 | for page in self.pages.values(): |
| @@ -230,6 +231,69 @@ class Preferences(Adw.PreferencesDialog) | ||
| 230 | 231 | group.add(box) |
| 231 | 232 | return group |
| 232 | 233 | |
| 234 | + # --- Analyse ----------------------------------------------------------- | |
| 235 | + | |
| 236 | + def _analysis_page(self): | |
| 237 | + page = Adw.PreferencesPage(title="Analyse", icon_name="power-profile-balanced-symbolic") | |
| 238 | + settings = self.win.settings | |
| 239 | + | |
| 240 | + mode_group = Adw.PreferencesGroup( | |
| 241 | + title="Energiesparmodus", | |
| 242 | + description="Stockfish denkt mit, während du überlegst – das lastet den Rechner bis zur " | |
| 243 | + "Zeitgrenze voll aus. Sparsam heißt: weniger Kerne und früher aufhören. " | |
| 244 | + "Hinweis und Zugzeichen bleiben verlässlich. Gilt ab dem nächsten Zug.", | |
| 245 | + ) | |
| 246 | + keys = [key for key, _ in energy.MODES] | |
| 247 | + mode = Adw.ComboRow(title="Energiesparmodus", model=Gtk.StringList.new([label for _, label in energy.MODES])) | |
| 248 | + current = energy.analysis_settings(settings).get("mode", "auto") | |
| 249 | + mode.set_selected(keys.index(current) if current in keys else 0) | |
| 250 | + mode_group.add(mode) | |
| 251 | + self.analysis_status = Adw.ActionRow(title="Gerade aktiv") | |
| 252 | + mode_group.add(self.analysis_status) | |
| 253 | + mode.connect("notify::selected", lambda row, _p: self._set_analysis("mode", keys[row.get_selected()])) | |
| 254 | + page.add(mode_group) | |
| 255 | + | |
| 256 | + for profile, title in (("normal", "Normal"), ("saver", "Energiesparen")): | |
| 257 | + group = Adw.PreferencesGroup(title=title) | |
| 258 | + values = energy.profile_values(settings, profile) | |
| 259 | + rows = ( | |
| 260 | + ("threads", "Threads", "Rechenkerne für Stockfish", 1, os.cpu_count() or 1, 1), | |
| 261 | + ("depth", "Maximale Tiefe", f"Halbzüge voraus; ab {energy.MIN_DEPTH} ist der Hinweis endgültig", | |
| 262 | + energy.MIN_DEPTH, energy.MAX_DEPTH, 1), | |
| 263 | + ("time", "Maximale Rechenzeit", "Sekunden pro Stellung", energy.MIN_TIME, energy.MAX_TIME, 5), | |
| 264 | + ) | |
| 265 | + for name, label, subtitle, low, high, page_step in rows: | |
| 266 | + row = Adw.SpinRow( | |
| 267 | + title=label, subtitle=subtitle, digits=0, | |
| 268 | + adjustment=Gtk.Adjustment(lower=low, upper=high, step_increment=1, page_increment=page_step), | |
| 269 | + ) | |
| 270 | + row.set_value(values[name]) | |
| 271 | + row.connect("notify::value", | |
| 272 | + lambda r, _p, pr=profile, n=name: self._set_analysis(n, int(r.get_value()), pr)) | |
| 273 | + group.add(row) | |
| 274 | + page.add(group) | |
| 275 | + self._refresh_analysis_status() | |
| 276 | + return page | |
| 277 | + | |
| 278 | + def _set_analysis(self, name, value, profile=None): | |
| 279 | + analysis = {k: dict(v) if isinstance(v, dict) else v | |
| 280 | + for k, v in energy.analysis_settings(self.win.settings).items()} | |
| 281 | + if profile is None: | |
| 282 | + analysis[name] = value | |
| 283 | + else: | |
| 284 | + analysis.setdefault(profile, {})[name] = value | |
| 285 | + self._set("analysis", analysis) | |
| 286 | + self._refresh_analysis_status() | |
| 287 | + | |
| 288 | + def _refresh_analysis_status(self): | |
| 289 | + profile, reason = energy.active_profile(self.win.settings) | |
| 290 | + values = energy.profile_values(self.win.settings, profile) | |
| 291 | + name = "Energiesparen" if profile == "saver" else "Normal" | |
| 292 | + self.analysis_status.set_subtitle( | |
| 293 | + f"{name} ({reason}): {values['threads']} Threads, bis Tiefe {values['depth']} " | |
| 294 | + f"oder {values['time']} s" | |
| 295 | + ) | |
| 296 | + | |
| 233 | 297 | # --- Lichess ----------------------------------------------------------- |
| 234 | 298 | |
| 235 | 299 | def _lichess_page(self): |
added tests/test_energy.py +78 −0
| @@ -0,0 +1,78 @@ | ||
| 1 | +import shutil | |
| 2 | +import threading | |
| 3 | +import unittest | |
| 4 | +from unittest import mock | |
| 5 | + | |
| 6 | +import chess | |
| 7 | +import chess.engine | |
| 8 | + | |
| 9 | +from schach import annotate, energy | |
| 10 | + | |
| 11 | + | |
| 12 | +class ProfileTest(unittest.TestCase): | |
| 13 | + def test_defaults(self): | |
| 14 | + self.assertEqual(energy.profile_values({}, "saver"), {"threads": 2, "depth": 18, "time": 10}) | |
| 15 | + normal = energy.profile_values({}, "normal") | |
| 16 | + self.assertEqual((normal["depth"], normal["time"]), (30, 30)) | |
| 17 | + | |
| 18 | + def test_threads_half_the_cpus_at_most_eight(self): | |
| 19 | + for cpus, threads in ((None, 1), (1, 1), (2, 1), (8, 4), (12, 6), (32, 8)): | |
| 20 | + with mock.patch("os.cpu_count", return_value=cpus): | |
| 21 | + self.assertEqual(energy.default_threads(), threads, cpus) | |
| 22 | + | |
| 23 | + def test_stored_values_override_and_are_clamped(self): | |
| 24 | + settings = {"analysis": {"saver": {"depth": 5, "time": 999, "threads": 3}}} | |
| 25 | + values = energy.profile_values(settings, "saver") | |
| 26 | + self.assertEqual(values["depth"], energy.MIN_DEPTH) # Hinweis braucht Tiefe 18 | |
| 27 | + self.assertEqual(values["time"], energy.MAX_TIME) | |
| 28 | + self.assertEqual(values["threads"], min(3, __import__("os").cpu_count())) | |
| 29 | + self.assertEqual(energy.profile_values(settings, "normal"), energy.defaults("normal")) | |
| 30 | + | |
| 31 | + def test_broken_settings_fall_back(self): | |
| 32 | + for broken in ({"analysis": None}, {"analysis": {"saver": "x"}}, {"analysis": {"saver": {"depth": "tief"}}}): | |
| 33 | + self.assertEqual(energy.profile_values(broken, "saver"), energy.defaults("saver")) | |
| 34 | + | |
| 35 | + | |
| 36 | +class ModeTest(unittest.TestCase): | |
| 37 | + def profile(self, mode, battery, saver): | |
| 38 | + return energy.active_profile({"analysis": {"mode": mode}}, battery=battery, saver=saver)[0] | |
| 39 | + | |
| 40 | + def test_auto(self): | |
| 41 | + self.assertEqual(self.profile("auto", False, False), "normal") | |
| 42 | + self.assertEqual(self.profile("auto", True, False), "saver") | |
| 43 | + self.assertEqual(self.profile("auto", False, True), "saver") # Systemprofil „Energiesparen“ | |
| 44 | + self.assertEqual(energy.active_profile({}, battery=True, saver=False)[0], "saver") # auto ist Standard | |
| 45 | + | |
| 46 | + def test_always_and_never_ignore_the_battery(self): | |
| 47 | + self.assertEqual(self.profile("always", False, False), "saver") | |
| 48 | + self.assertEqual(self.profile("never", True, True), "normal") | |
| 49 | + | |
| 50 | + def test_without_psutil_counts_as_plugged_in(self): | |
| 51 | + with mock.patch.dict("sys.modules", {"psutil": None}): | |
| 52 | + self.assertIsNone(energy.on_battery()) | |
| 53 | + | |
| 54 | + def test_think_settings(self): | |
| 55 | + threads, limit = energy.think_settings({"analysis": {"mode": "always"}}) | |
| 56 | + self.assertEqual((threads, limit.depth, limit.time), (2, 18, 10)) | |
| 57 | + | |
| 58 | + | |
| 59 | +@unittest.skipUnless(shutil.which("stockfish"), "stockfish nicht installiert") | |
| 60 | +class ThinkLimitTest(unittest.TestCase): | |
| 61 | + def test_think_job_obeys_limit_and_threads(self): | |
| 62 | + engine = chess.engine.SimpleEngine.popen_uci("stockfish") | |
| 63 | + try: | |
| 64 | + snapshots = [] | |
| 65 | + job = annotate.think_job(chess.Board(), annotate.Thinking(), snapshots.append, | |
| 66 | + limit=chess.engine.Limit(depth=10), threads=1) | |
| 67 | + worker = threading.Thread(target=lambda: snapshots.append(job(engine))) | |
| 68 | + worker.start() | |
| 69 | + worker.join(30) | |
| 70 | + self.assertFalse(worker.is_alive()) | |
| 71 | + self.assertEqual(max(s["depth"] for s in snapshots), 10) | |
| 72 | + self.assertEqual(engine.protocol.config.get("Threads"), 1) | |
| 73 | + finally: | |
| 74 | + engine.quit() | |
| 75 | + | |
| 76 | + | |
| 77 | +if __name__ == "__main__": | |
| 78 | + unittest.main() | |