See Subscriber.receive_in_background(..): currently, it expects the handler to be async, which is rarely necessary. The library should also accept synchronous handlers. The implementation should be trivial --- just call the handler using the synchronous syntax and check if the result is an Awaitable[]; if so, await on it, otherwise do nothing:
See
Subscriber.receive_in_background(..)
: currently, it expects the handler to be async, which is rarely necessary. The library should also accept synchronous handlers. The implementation should be trivial --- just call the handler using the synchronous syntax and check if the result is anAwaitable[]
; if so,await
on it, otherwise do nothing:https://github.com/UAVCAN/pyuavcan/blob/4ec55a80f8fd3dd21a3d08102837c43d832b71a3/pyuavcan/presentation/_port/_subscriber.py#L104-L110
The same logic might also work for
Server.serve(..)
et al.