Skip to content

Fix TUI quit hang on Python 3.13#195

Merged
balloob merged 3 commits intomainfrom
codex/fix-tui-quit-hang
Mar 25, 2026
Merged

Fix TUI quit hang on Python 3.13#195
balloob merged 3 commits intomainfrom
codex/fix-tui-quit-hang

Conversation

@balloob
Copy link
Copy Markdown
Contributor

@balloob balloob commented Mar 25, 2026

Summary

  • stop using the event loop default executor for blocking readchar.readkey() calls
  • move keyboard reads onto a dedicated daemon thread and forward keys back to the asyncio loop
  • preserve existing TUI key handling while avoiding hangs during interpreter shutdown

Testing

  • ./scripts/run-in-env.sh pre-commit run -a

Copilot AI review requested due to automatic review settings March 25, 2026 03:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Python 3.13 shutdown hang in the Sendspin TUI by removing reliance on the asyncio event loop’s default executor for blocking readchar.readkey() calls, instead reading keys on a dedicated background thread and forwarding them into the asyncio loop.

Changes:

  • Add a dedicated daemon thread to perform blocking readchar.readkey() reads.
  • Forward keypresses back to the asyncio loop via loop.call_soon_threadsafe() and an asyncio.Queue.
  • Replace run_in_executor() usage with await key_queue.get() in the main keyboard loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@balloob balloob added the bugfix Fixes a bug label Mar 25, 2026
@balloob balloob merged commit 30848c6 into main Mar 25, 2026
1 check passed
@balloob balloob deleted the codex/fix-tui-quit-hang branch March 25, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants