Skip to content

Fix: make widget.loading thread-safe (closes #5108)#6617

Open
jtvhd6 wants to merge 1 commit into
Textualize:mainfrom
jtvhd6:fix/loading-thread-safe
Open

Fix: make widget.loading thread-safe (closes #5108)#6617
jtvhd6 wants to merge 1 commit into
Textualize:mainfrom
jtvhd6:fix/loading-thread-safe

Conversation

@jtvhd6

@jtvhd6 jtvhd6 commented Jul 1, 2026

Copy link
Copy Markdown

Closes #5108.

_watch_loading now checks whether it's running on the app's own
thread before mutating the widget's DOM. If loading is set from a
worker thread, the update is routed through App.call_from_thread
instead of touching the UI directly.

Testing

  • Added test_loading_set_from_worker_thread in tests/test_loading.py,
    which sets .loading = True from a real background thread via
    run_worker(thread=True) and asserts it doesn't raise and updates
    the reactive correctly.
  • poetry run pytest tests/ -k loading -q — 20 passed.
  • poetry run ruff check — all checks passed.
  • poetry run mypy src/textual/widget.py — confirmed 12 pre-existing
    errors are unrelated to this change (same errors present on main).

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.

Make Loading Indicator thread-safe

1 participant