From 9985262a5353e81fb21edb9d43307d4592d501da Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 2 May 2024 11:00:12 -0500 Subject: [PATCH 1/3] Block pyserial-asyncio in favor of pyserial-asyncio-fast pyserial-asyncio does blocking I/O in asyncio loop and is not maintained --- homeassistant/package_constraints.txt | 4 ++++ script/gen_requirements_all.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 21bd4fb2d1b..eb1bfe5ff21 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -197,3 +197,7 @@ scapy>=2.5.0 # Only tuf>=4 includes a constraint to <1.0. # https://github.com/theupdateframework/python-tuf/releases/tag/v4.0.0 tuf>=4.0.0 + +# pyserial-asyncio does blocking I/O in asyncio loop, use pyserial-asyncio-fast +# instead as pyserial-asyncio is not maintained +pyserial-asyncio==1000000000.0.0 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 1f2f4bcab66..d0341aab03e 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -219,6 +219,10 @@ scapy>=2.5.0 # Only tuf>=4 includes a constraint to <1.0. # https://github.com/theupdateframework/python-tuf/releases/tag/v4.0.0 tuf>=4.0.0 + +# pyserial-asyncio does blocking I/O in asyncio loop, use pyserial-asyncio-fast +# instead as pyserial-asyncio is not maintained +pyserial-asyncio==1000000000.0.0 """ GENERATED_MESSAGE = ( From 998a4eab9eb7d1569cd1af3f51a0080007123c15 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 2 May 2024 11:04:45 -0500 Subject: [PATCH 2/3] Replace pyserial-asyncio with pyserial-asyncio-fast in serial pyserial-asyncio is unmantained and does blocking I/O in the event loop --- homeassistant/components/serial/manifest.json | 2 +- homeassistant/components/serial/sensor.py | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/serial/manifest.json b/homeassistant/components/serial/manifest.json index 5a097572d98..a8bcc335991 100644 --- a/homeassistant/components/serial/manifest.json +++ b/homeassistant/components/serial/manifest.json @@ -4,5 +4,5 @@ "codeowners": ["@fabaff"], "documentation": "https://www.home-assistant.io/integrations/serial", "iot_class": "local_polling", - "requirements": ["pyserial-asyncio==0.6"] + "requirements": ["pyserial-asyncio-fast==0.11"] } diff --git a/homeassistant/components/serial/sensor.py b/homeassistant/components/serial/sensor.py index 5f2b1ea3c3c..9d60877bd1b 100644 --- a/homeassistant/components/serial/sensor.py +++ b/homeassistant/components/serial/sensor.py @@ -7,7 +7,7 @@ import json import logging from serial import SerialException -import serial_asyncio +import serial_asyncio_fast as serial_asyncio import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity diff --git a/requirements_all.txt b/requirements_all.txt index 87e4fb9e77d..2ebb5bc9c72 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2119,10 +2119,10 @@ pyschlage==2024.2.0 # homeassistant.components.sensibo pysensibo==1.0.36 +# homeassistant.components.serial # homeassistant.components.zha pyserial-asyncio-fast==0.11 -# homeassistant.components.serial # homeassistant.components.zha pyserial-asyncio==0.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 908792f4069..2c69a834b6a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1658,10 +1658,10 @@ pyschlage==2024.2.0 # homeassistant.components.sensibo pysensibo==1.0.36 +# homeassistant.components.serial # homeassistant.components.zha pyserial-asyncio-fast==0.11 -# homeassistant.components.serial # homeassistant.components.zha pyserial-asyncio==0.6 From 7e3e82746fb41c5c00bd7a3c177e4b519bcf7458 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 2 May 2024 11:09:43 -0500 Subject: [PATCH 3/3] Drop pyserial-asyncio from zha This may not be possible yet, but the long term goal is to get rid of pyserial-asyncio everywhere so we can prevent future integrations from using it and than we have to go though the effort of getting them to replace it with pyserial-asyncio-fast to avoid the event loop being blocked needed for https://github.com/home-assistant/core/pull/116635 --- homeassistant/components/zha/manifest.json | 1 - requirements_all.txt | 1 - requirements_test_all.txt | 4 ---- 3 files changed, 6 deletions(-) diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index b1511b2f5bb..1c32a9b6149 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -23,7 +23,6 @@ "requirements": [ "bellows==0.38.3", "pyserial==3.5", - "pyserial-asyncio==0.6", "zha-quirks==0.0.115", "zigpy-deconz==0.23.1", "zigpy==0.64.0", diff --git a/requirements_all.txt b/requirements_all.txt index 87e4fb9e77d..1e64adc3814 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2123,7 +2123,6 @@ pysensibo==1.0.36 pyserial-asyncio-fast==0.11 # homeassistant.components.serial -# homeassistant.components.zha pyserial-asyncio==0.6 # homeassistant.components.acer_projector diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 908792f4069..0b5ccba7f39 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1661,10 +1661,6 @@ pysensibo==1.0.36 # homeassistant.components.zha pyserial-asyncio-fast==0.11 -# homeassistant.components.serial -# homeassistant.components.zha -pyserial-asyncio==0.6 - # homeassistant.components.acer_projector # homeassistant.components.crownstone # homeassistant.components.usb