Parrot-Developers/olympe

[Question] Olympe SDK support for AsyncIO

Opened this issue · 1 comments

We are building a gRPC server using the gRPC AsyncIO API and we need to integrate Olympe for controlling a Parrot Drone from the gRPC services. Since it is strongly recommended not to perform blocking operations inside AsyncIO event loop, we need to control the drone through non-blocking operations in order to allow the event loop to execute any other coroutines that may be waiting to execute.

Does Olympe provide fully non-blocking operations?

Olympe expectation objects are awaitable objects in an olympe.concurrent.Loop event loop (not asyncio). To use olympe expectation objects in an asyncio event loop you'd need to wrap them with an asyncio.Future (example: expectation.add_done_callback(lambda e: loop.call_soon_threadsafe(lambda: fut.set_result(e.success()))) with 'loop' an asyncio loop and 'fut' a Future associated with this loop.).

See: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_soon_threadsafe