Fix macOS daemon crash: remove non-existent wait_until_ready call#56
Open
GordonHannan wants to merge 1 commit into
Open
Fix macOS daemon crash: remove non-existent wait_until_ready call#56GordonHannan wants to merge 1 commit into
GordonHannan wants to merge 1 commit into
Conversation
bleak's CentralManagerDelegate does not expose a wait_until_ready() method. State readiness and error raising (BT off, unauthorized) happen inside __init__, so the extra await was a NameError that caused the daemon to SIGABRT on every launch when started via launchd. Also documents that the daemon requires Python 3.10+ (str | None union syntax is used throughout the file). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Removes an invalid wait_until_ready() call from the macOS CoreBluetooth path so the launchd-managed daemon no longer crashes at startup due to an AttributeError, allowing BLE logic to proceed normally.
Changes:
- Removed
await mgr.wait_until_ready()from_get_cb_manager()because the method does not exist on bleak’sCentralManagerDelegate. - Updated the inline comment to reflect that
CentralManagerDelegate()is expected to raise on Bluetooth off/unauthorized conditions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
You have a test plan but nothing on it is checked. Have you tested this? |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS, the launchd-managed daemon crashed immediately on every start with
SIGABRT, producing repeated "Python quit unexpectedly" dialogs. The daemon would print its startup banner and exit before attempting any BLE connection.Root cause
_get_cb_manager()calledawait mgr.wait_until_ready()on aCentralManagerDelegateinstance, but this method does not exist in bleak's API. State readiness and error signalling (Bluetooth off, unauthorized) are handled insideCentralManagerDelegate.__init__itself — calling a non-existent method raisedAttributeErrorbefore any BLE work could begin.Fix
Remove the
await mgr.wait_until_ready()line.CentralManagerDelegate()already raisesBleakErroron failure, so no additional readiness check is needed.Notes
str | Noneunion syntax is used throughout). Venvs built with Python 3.9 (macOS system default) also crash at import time withTypeError: unsupported operand type(s) for |.Test plan
python3 -m venv daemon/.venv && daemon/.venv/bin/pip install bleak httpxlaunchctl kickstart -k gui/$(id -u)/com.user.claude-usage-daemon~/Library/Logs/claude-usage-daemon.out.log)🤖 Generated with Claude Code