Olivier Monnom’s Post

🟧 I just published `auserial` on PyPI — a truly async serial port for Linux/macOS in ~80 lines of standard library code. The problem: none of the existing libraries are satisfying for asyncio code. • `pyserial` blocks the entire thread on read() → freezes the event loop. • `aioserial` wraps pyserial in run_in_executor → one thread per I/O. • `pyserial-asyncio` forces Transport/Protocol → verbose, callback-driven. `auserial` plugs the file descriptor directly into the asyncio loop via add_reader / add_writer — which means epoll on Linux, kqueue on macOS. Zero threads, zero polling, just the kernel notifying when the fd is ready. async with AUSerial("/dev/ttyUSB0") as serial: await serial.write(b"AT\r\n") data = await serial.read() While one coroutine is parked on a read(), the others keep running normally — that's the whole point. No external dependencies. Just os, termios, asyncio. PEP 561 compliant (types propagate to consumers), tested via PTY. 🔗 PyPI: pypi.org/project/auserial 🔗 Code: https://lnkd.in/eFftFZdQ Feedback welcome — and if you have a use case where pyserial-asyncio made you grit your teeth, I'd love to hear about it. #Python #asyncio #OpenSource #SerialPort #Embedded #Linux #macOS

You should put on crayes.io better than github

Like
Reply

To view or add a comment, sign in

Explore content categories