fix(python-sdk): pass CommandFactory (not invoked coroutine) to observables#918
Open
akeildev wants to merge 1 commit into
Open
fix(python-sdk): pass CommandFactory (not invoked coroutine) to observables#918akeildev wants to merge 1 commit into
akeildev wants to merge 1 commit into
Conversation
…vables
`GoproObserverDistinctInitial.start()` calls `self._register_command_factory()`,
and the type is `CommandFactory = Callable[[], Coroutine[...]]` — i.e. a factory
that *returns* a coroutine. Several call sites instead passed an already-invoked
coroutine, so `start()` tried to call a coroutine object:
TypeError: 'coroutine' object is not callable
This breaks `AccessPointFeature.connect()` (and therefore COHN provisioning,
which depends on it) deterministically, as well as `LiveStreamController`'s
status observable.
Fix the call sites to pass factories, matching the correct pattern already used
elsewhere (e.g. cohn_feature.py, api/builders.py):
- access_point_feature.py: wrap `scan_wifi_networks()` in a lambda; build the
wifi-connect command with functools.partial.
- livestream.py: wrap register/unregister status commands in lambdas.
Tested against a HERO12 Black: `access_point.connect()` now completes the wifi
scan and returns a normal Result instead of raising.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017S8amPPZwqFt7hqdNk3yJh
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.
Description
GoproObserverDistinctInitial.start()invokes the registration command as a factory:Several call sites pass an already-invoked coroutine instead of a factory, so
start()ends up calling a coroutine object:This makes
AccessPointFeature.connect()fail deterministically, which in turn breaks COHN provisioning (it callsaccess_point.connect()), and also affectsLiveStreamController's status observable.Affected call sites (passing
coro()where aCallable[[], coro]is expected)features/access_point_feature.py:61—register_command=self._gopro.ble_command.scan_wifi_networks()features/access_point_feature.py:104—register_command=command(wherecommandis an invoked coroutine)features/streaming/livestream.py:82,85—register_command/unregister_commandThe correct pattern (a
lambda:factory) is already used elsewhere, e.g.features/cohn_feature.py:69andapi/builders.py.Fix
Wrap these in factories:
scan_wifi_networks()→lambda: ...scan_wifi_networks()functools.partial(...)lambda: ...No behavior change beyond deferring coroutine creation to call time, as the type contract intends.
Testing
Verified against a HERO12 Black. Before:
gopro.access_point.connect(ssid, pw)raised'coroutine' object is not callable. After: it completes the WiFi scan and returns a normalResult(e.g. a clean<Failure: Could not find SSID: ...>for a non-existent SSID, and provisioning proceeds for a real one).py_compilepasses on both files.Related
May explain user-reported COHN provisioning /
scan_wifi_networksfailures discussed in #744.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_017S8amPPZwqFt7hqdNk3yJh