10000 Switch usage of asyncio.wait_for to async_timeout by bdraco · Pull Request #337 · JeffLIrion/python-androidtv · GitHub
[go: up one dir, main page]

Skip to content

Switch usage of asyncio.wait_for to async_timeout #337

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

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
< 10000 div data-show-on-forbidden-error hidden>

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if python --version 2>&1 | grep -q "Python 2"; then pip install mock rsa==4.0; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then pip install aiofiles adb-shell[usb]; fi
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then pip install aiofiles async_timeout adb-shell[usb]; fi
- name: Check formatting with black
run: |
if python --version 2>&1 | grep -q "Python 3.7" || python --version 2>&1 | grep -q "Python 3.8" || python --version 2>&1 | grep -q "Python 3.9" || python --version 2>&1 | grep -q "Python 3.10"; then pip install black && make lint-black; fi
Expand Down
4 changes: 3 additions & 1 deletion androidtv/adb_manager/adb_manager_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.constants import DEFAULT_PUSH_MODE, DEFAULT_READ_TIMEOUT_S
import aiofiles
import async_timeout
from ppadb.client import Client

from ..constants import (
Expand Down Expand Up @@ -164,7 +165,8 @@ async def _acquire(lock, timeout=DEFAULT_LOCK_TIMEOUT_S):
try:
acquired = False
try:
acquired = await asyncio.wait_for(lock.acquire(), timeout)
async with async_timeout.timeout(timeout):
acquired = await lock.acquire()
if not acquired:
raise LockNotAcquiredException
yield acquired
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
author_email="jefflirion@users.noreply.github.com",
packages=["androidtv", "androidtv.adb_manager", "androidtv.basetv", "androidtv.androidtv", "androidtv.firetv"],
install_requires=["adb-shell>=0.4.0", "pure-python-adb>=0.3.0.dev0"],
extras_require={"async": ["aiofiles>=0.4.0"], "usb": ["adb-shell[usb]>=0.4.0"]},
extras_require={"async": ["aiofiles>=0.4.0", "async_timeout>=3.0.0"], "usb": ["adb-shell[usb]>=0.4.0"]},
classifiers=[
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down
0