最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Using subscribe() method in an asyncio stack - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论