pykeadhcp icon indicating copy to clipboard operation
pykeadhcp copied to clipboard

Add Async support

Open devyntk opened this issue 10 months ago • 0 comments

Daemon/Area

All Daemons

Feature/Enhancement you are proposing

Add the ability to use this library's endpoints with Async Python. Either creating a seperate AsyncKea class (similar to the implementation of HTTPX) or optionally returning a Promise from methods (like redis-py/valkey-py does).

At the simplest, this would be as easy as changing from httpx.Client to httpx.AsyncClient internally, as the API is identical between the two, the latter just returning a Promise to be awaited instead. The tricky part of this is expressing this to Python's typing system (which, to me, strong types is the largest advantage of this Library). I am unsure if there is a way of making the Daemon classes generic of Client vs AsyncClient, and then returning different types for the two variants of the generic client, but that feels the cleanest solution to me if possible.

Reason for Feature/Enhancement

Async Python is very popular for networked applications, especially for anything relating to IO, and while the Kea daemon has very little latency, there is still blocking IO involved in this application. My use case for this library is within a Litestar-based web API, which natively prefers Async programming instead. Right now my current solution is using asyncio.run_in_executor for all of the calls into this library as the native execution handling, model parsing, and other benefits are very enticing.

devyntk avatar Jun 16 '25 14:06 devyntk