Skip to content

Queue async ADB commands instead of dropping them during busy operations - #374

Open
Komzpa wants to merge 2 commits into
JeffLIrion:masterfrom
Komzpa:fix/async-command-queue-20261015
Open

Komzpa wants to merge 2 commits into
JeffLIrion:masterfrom
Komzpa:fix/async-command-queue-20261015

Conversation

@Komzpa

@Komzpa Komzpa commented Oct 14, 2026

Copy link
Copy Markdown

ADB commands can be discarded while a screenshot or another valid operation holds the connection lock for more than three seconds. The transport can still be healthy: _acquire raises LockNotAcquiredException before the queued command gets a chance to run. Home Assistant handles that exception by skipping the command.

Wait for the asynchronous connection lock by default. Explicit acquisition deadlines still work, and the ADB transport keeps its existing network timeouts. Cancelling a waiting command leaves the active command’s lock intact.

The regression test holds a real asyncio.Lock beyond the previous three-second limit, then checks that the queued shell command completes after release. It fails with LockNotAcquiredException on the original code. A second test covers cancellation and subsequent connection reuse.

Validation: python -m unittest discover -s tests -t . ran 236 tests successfully (one skipped). Black checks both changed files with the project settings; Flake8 checks the changed source file.

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