-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release/0.19.2 #1116
Merged
Merged
Release/0.19.2 #1116
Conversation
This file contains 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
Python 3.11 crashes on Windows when connecting to a device: Traceback (most recent call last): File "C:\Users\david\Documents\GitHub\Pybricks\bleak\examples\service_explorer.py", line 64, in <module> asyncio.run(main(sys.argv[1] if len(sys.argv) == 2 else ADDRESS)) File "C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\david\Documents\GitHub\Pybricks\bleak\examples\service_explorer.py", line 29, in main async with BleakClient(address) as client: File "C:\Users\david\Documents\GitHub\Pybricks\bleak\bleak\__init__.py", line 433, in __aenter__ await self.connect() File "C:\Users\david\Documents\GitHub\Pybricks\bleak\bleak\__init__.py", line 471, in connect return await self._backend.connect(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await self.get_services() File "C:\Users\david\Documents\GitHub\Pybricks\bleak\bleak\backends\winrt\client.py", line 574, in get_services File "C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 418, in wait return await _wait(fs, timeout, return_when, loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\david\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 522, in _wait f.add_done_callback(_on_completion) ^^^^^^^^^^^^^^^^^^^ AttributeError: '_bleak_winrt_Windows_Foundation.IAsyncOperation' object has no attribute 'add_done_callback' asyncio.wait() requires an asyncio.Task or asyncio.Future, but we were passing a WinRT IAsyncResult object. So we have to wrap it in a coroutine and then in a task to avoid the error.
This changes the cache mode when getting services after a ServicesChanged event in the WinRT backend. This matches the recommendation of the docs. https://learn.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothledevice.gattserviceschanged?view=winrt-20348
The fix from #1101 causes the following when run with `python3.10 -X dev`. ERROR:asyncio:Exception in callback Future.set_result(<Future cance...events.py:429>, <_bleak_winrt...001C33C60B100>) handle: <Handle Future.set_result(<Future cance...events.py:429>, <_bleak_winrt...001C33C60B100>)> Traceback (most recent call last): File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) asyncio.exceptions.InvalidStateError: invalid state ERROR:asyncio:Exception in callback Future.set_result(<Future cance...events.py:429>, <_bleak_winrt...001C33C60BFC0>) handle: <Handle Future.set_result(<Future cance...events.py:429>, <_bleak_winrt...001C33C60BFC0>)> Traceback (most recent call last): File "C:\Users\david\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) asyncio.exceptions.InvalidStateError: invalid state This adds a new FutureLike wrapper to make the IAsyncOperation object look like an asyncio.Future instead of wrapping it in a task.
When run with python3.10 -dev X, we get a warning that warn is deprecated and we should replace it with warning.
Apparently, BlueZ will sometimes request to remove properties that were not set in the first place. Fixes: #1107
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.
Fixed
KeyError
crash in BlueZ backend when removing non-existent property. Fixes Why some times rasberry pi will raise this log ->KeyError: 'Icon' #1107.