I haven’t seen a general purpose way to use our Qt event loop with asyncio, so if you or anyone here has a good solution please post it.
The WebServer module in Slicer uses the QSocketNotifier class to add a python socket’s file number to the Qt event loop so that everything is event driven. I find this to be a good solution.
There should be a way to do something similar with asyncio such that events from Qt can be used to trigger event handling in asyncio code, but when I looked a few years ago it seemed that the core event loops in asyncio were not set up for this use case. Maybe there are good solutions by now.
You may consider using the WebServer module in Slicer. Commonly needed features are exposed via the slicer endpoint, it has an exec option to allow full access to the entire Slicer Python API, and you can also start a SlicerHTTPServer with your own RequestHandler to support any custom requests. So, you actually don’t need to go down to the asincio or QSocketNotifier level or deal with any communication stuff at all, just implement a simple Python class that has canHandleRequest and handleRequest methods (Slicer’s default request handler can serve as an example).