-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for tracing down the issue with bluetoothctl version
As it turned out, there was a regression in Python 3.11.1 related to loss of output from subprocesses. Refs: hbldh/bleak#1183 python/cpython#100133
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import asyncio | ||
import multiprocessing | ||
import os | ||
|
||
import bleak.backends.bluezdbus.version as bv | ||
|
||
async def subprocess_task(): | ||
version_output = await bv._get_bluetoothctl_version() | ||
if version_output: | ||
major, minor = tuple(map(int, version_output.groups())) | ||
print(major, minor) | ||
else: | ||
print("No version_output") | ||
await asyncio.sleep(1.0) | ||
|
||
def subprocess_work(): | ||
sploop = asyncio.new_event_loop() | ||
print(f"Inner loop: {sploop} {os.getpid()} {sploop._selector}") | ||
sploop.run_until_complete(subprocess_task()) | ||
|
||
|
||
if __name__ == '__main__': | ||
multiprocessing.set_start_method('spawn', force=True) | ||
loop = asyncio.new_event_loop() | ||
print(f"Outer loop: {loop} {os.getpid()} {loop._selector}") | ||
loop.run_until_complete(subprocess_task()) | ||
p = multiprocessing.Process(target=subprocess_work) | ||
p.start() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import bleak.backends.bluezdbus.version as bv | ||
|
||
import pytest | ||
|
||
@pytest.mark.asyncio | ||
async def test_version(): | ||
version_output = await bv._get_bluetoothctl_version() | ||
assert version_output | ||
major, minor = tuple(map(int, version_output.groups())) | ||
assert major == 5 | ||
assert minor == 55 | ||
|
||
|
||
|