From e980b52521aa185820fea9215d5282534b0a8426 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 22 Jun 2024 15:01:13 -0500 Subject: [PATCH] Switch to pyserial-asyncio-fast to fix event loop being blocked (#34) --- aioraven/serial.py | 6 +++--- pyproject.toml | 2 +- test/mock_device.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aioraven/serial.py b/aioraven/serial.py index c1f5c1f..f71aa09 100644 --- a/aioraven/serial.py +++ b/aioraven/serial.py @@ -12,7 +12,7 @@ from aioraven.streams import RAVEnStreamDevice from aioraven.streams import RAVEnWriter from serial import SerialException -from serial_asyncio import create_serial_connection +from serial_asyncio_fast import create_serial_connection async def open_serial_connection( @@ -25,7 +25,7 @@ async def open_serial_connection( Establish a serial connection to a RAVEn device. Positional and keyword arguments are passed to - `serial_asyncio.create_serial_connection()`. + `serial_asyncio_fast.create_serial_connection()`. :param loop: The event loop instance to use. """ @@ -57,7 +57,7 @@ def __init__( Construct a RAVEnSerialDevice. Additional positional and keyword arguments are passed to - `serial_asyncio.create_serial_connection()`. + `serial_asyncio_fast.create_serial_connection()`. :param url: The pyserial URL of the device to connect to. :param loop: The event loop instance to use. diff --git a/pyproject.toml b/pyproject.toml index 834ad7c..cdc2807 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ dependencies = [ "iso4217", "pyserial>=2.5", - "pyserial-asyncio", + "pyserial-asyncio-fast", ] dynamic = ["version"] diff --git a/test/mock_device.py b/test/mock_device.py index 04cfd31..93ba278 100644 --- a/test/mock_device.py +++ b/test/mock_device.py @@ -14,7 +14,7 @@ from typing import TypeVar from typing import Union -import serial_asyncio +import serial_asyncio_fast _T = TypeVar('_T') @@ -278,7 +278,7 @@ async def main(argv: list[str] = sys.argv) -> Optional[int]: sys.stdin.buffer, sys.stdout.buffer) elif len(argv) == 2: read_transport = None - reader, writer = await serial_asyncio.open_serial_connection( + reader, writer = await serial_asyncio_fast.open_serial_connection( url=argv[1]) else: print(f'Usage: {argv[0]} [DEVICE_PATH]', file=sys.stderr)