Is google.cloud.pubsub_v1.PublisherClient Thread safe?

亡梦爱人 提交于 2019-12-12 19:09:26

问题


I am using google cloud PubSub and was wondering whether google.cloud.pubsub_v1.PublisherClient was thread safe. Do I need to pass a new instance of this object to each threading.Thread or is it safe to share the same instance across threads?


回答1:


It depends on the client library you are using.

This Python client library is not thread safe due to being built on top of the httplib2 library, which is not thread-safe. But, as the first link says, this is an old library. The newer Python library for Pub/Sub is thread safe.

Other Google client libraries are "thread safe" too. The .NET one, for example, was bult with the convention in mind that all static members should be thread-safe.



来源:https://stackoverflow.com/questions/52659169/is-google-cloud-pubsub-v1-publisherclient-thread-safe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!