FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bugfix: fix threading races and concurrency in moonrakerComm/RepeatedTimer by gmmcosta15 · Pull Request #211 · BlocksTechnology/BlocksScreen · GitHub

bugfix: fix threading races and concurrency in moonrakerComm/RepeatedTimer - #211

Open
gmmcosta15 wants to merge 15 commits into
devfrom
bugfix/threading-concurrency
Open

bugfix: fix threading races and concurrency in moonrakerComm/RepeatedTimer#211
gmmcosta15 wants to merge 15 commits into
devfrom
bugfix/threading-concurrency

Conversation

Copy link
Copy Markdown
Collaborator
  • Feature
  • Bug fix
  • Code refactor
  • Documentation

Description

  • Move connected, connecting, _reconnect_count, callback_table from class-level to __init__ to prevent shared state across instances.
  • Add _state_lock (RLock) and _request_lock guarding all reads/writes to those vars.
  • Fix mutable default argument params={} → params=None in send_request.
  • Fix unbound super() in OneShotTokenError.
  • Guard _retry_timer with None check before stopTimer/startTimer; stop existing timer in try_connection before creating a new one (prevents orphaned threads).
  • Replace sendEvent → postEvent for safe cross-thread event delivery.
  • Wrap json.loads in try/except; use .get() on all external response dicts.
  • Add klippy startup/disconnected retry cap (30 attempts) to prevent infinite reconnect loop.
  • Add join(timeout=self.timeout+1) on _wst to avoid indefinite block on shutdown.
  • Fix RepeatedTimer: inverted stopEvent semantics (set=stop, clear=running).

Motivation

The WebSocket layer had multiple threading races and incorrect cross-thread event dispatch causing UI freezes and crashes on Pi hardware. RepeatedTimer had inverted stop-event logic causing timers to never stop correctly. These are the root-cause fixes for the most severe class of bugs in #200.

Copy link
Copy Markdown
Member

Solid PR, solves a bunch of probable issues

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL