Python: Provide APIs and reusable pattern for Positron comm handlers to send results out of order
In the data explorer, we have some backend RPC methods that are fast (get_data_values, get_state, etc.) and some that are slow (get_column_profiles). Currently, all methods are executed synchronously and return their results in order, calling the PositronComm.send_result method.
Positron sends a unique message id to the kernel, but all of the comm handlers appear to assume that each time the on_msg callback message handler is called, that a result is returned before the next message is handled. I do not see any cases in positron_ipykernel where comm results are returned out of order.
Ideally, we will be able to move slow RPC handlers into asyncio coroutines, allowing fast RPC handlers to return while the slower methods run in parallel. Since some of these slower methods call into C functions that release the GIL, this should work fine.