Skip to content

Multiple fixes to bring the code to work with latest version of Python3#1

Open
nrathaus wants to merge 13 commits intosraodev:masterfrom
nrathaus:master
Open

Multiple fixes to bring the code to work with latest version of Python3#1
nrathaus wants to merge 13 commits intosraodev:masterfrom
nrathaus:master

Conversation

@nrathaus
Copy link
Copy Markdown

  1. Styling and coding that work with Python3
  2. Move to newer version of pybluez and pickle
  3. Better handling of errors
  4. Send data as bytes and receive it as bytes
  5. Retry connections in case it (previously) failed

sraodev pushed a commit that referenced this pull request Apr 30, 2026
PR #1 was opened against the original root-level scripts in 2023 and
no longer applies cleanly to the refactored sdk/python/ tree, but two
of its fixes are still real and weren't ported during the refactor.

- ClientSettings: connect_retries (default 5) and connect_backoff_seconds
  (default 1.0). Mirrors the discovery_retries / discovery_backoff_seconds
  pattern already in place.
- ClientSocketManager.connect(): wrap the connect call in a retry loop
  with the configured backoff. Bluetooth connect() is genuinely flaky
  in practice; the original PR did this with a hardcoded attempt > 5
  guard, here it is config-driven and logs per attempt. Last error is
  preserved as the raised BluetoothServerError's cause.
- install_dependencies.sh + sdk/python/README: install pybluez from
  github.com/pybluez/pybluez instead of PyPI. The PyPI distribution
  hasn't been updated in years and fails to build on Python 3.10+.

Not adopted from PR #1:
- Binary 2-byte little-endian length framing — caps payloads at 64KB
  and would regress the current decimal-string framing on both sides.
- bare-Exception catches and sys.exit(0) on failure — the current
  module raises typed BluetoothClientError / BluetoothServerError,
  which is strictly better for callers and tests.

Smoke-tested the retry path with a stubbed bluetooth module (3 attempts
with 0.01s backoff completed in ~20ms; each attempt logged; final
exception carried the BluetoothError cause).
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.

1 participant