ADB sessions for Python with cancellation, output limits, and foreground/background scheduling. Python 3.10+, with no third-party runtime dependencies.
Install Android Platform Tools
and make adb available on your PATH. Then install adblane from this checkout:
python -m pip install .Choose a device serial from adb devices:
from adblane import AdbSession
with AdbSession("YOUR_DEVICE_SERIAL") as device:
sdk = device.read(
"getprop ro.build.version.sdk",
timeout=5,
max_bytes=4096,
)
print(sdk.decode().strip())read() returns bytes and checks the remote command's exit status. Share one
session between threads working with the same device. The context manager closes
the session and its local ADB clients when you are done.
- Foreground and background priorities, with a shared concurrency limit.
- Cancellation through
threading.Eventand timeouts for queued or active calls. - Output size limits and optional exact-length checks.
- Reusable shell connections for small reads and
exec-outfor larger reads. - Explicit, bounded retries for read-only operations.
MIT. Install Android Platform Tools separately.