I want to use pubsub in an application that uses asyncio as a basic way of achieving I/O concurrency. The default Google SDK, however doesn't offer async methods (I have tried gcloud-aio-pubsub, but it only supports pull methods, so the latency is very bad).
With publishing and topic/subscription management I could just use wrap_future, as the publish() method and most other return an object supporting Future
protocol.
My question is about the subscribe
method. According to the documentation it runs the StreamingPull in a separate thread. Also, if I understand the code correctly, I see that the callback is called in a threat that is taken from a pool.
My idea to use it with asyncio is to replace the default Scheduler with one that would schedule the coroutines in the main thread's event loop. Is it a good approach? Any considerations that I need to take into account?