JeffLIrion / python-androidtv

Communicate with an Android TV or Fire TV device via ADB over a network.
MIT License
165 stars 57 forks source link

Switch usage of asyncio.wait_for to async_timeout #337

Closed bdraco closed 1 year ago

bdraco commented 1 year ago

asyncio.wait_for creates another tasks which leads to some race conditions in cancelation and a performance hit

cpython 3.12 will change the underlying implementation of asyncio.wait_for to use asyncio.wait but that is still a long way off for many people:

https://github.com/python/cpython/pull/98518

seen on profile courtesy of @Madelena

wait_for

bdraco commented 1 year ago

I don't have an androidtv device though so I can't test this. I'm fixing this as a result of investigating a sluggish Home Assistant instance from the provided profile data above.

JeffLIrion commented 1 year ago

Thanks! I made the same change in adb-shell: https://github.com/JeffLIrion/adb_shell/pull/222