google.cloud.pubsub_v1.PublisherClient线程安全吗? [英] Is google.cloud.pubsub_v1.PublisherClient Thread safe?

查看:85
本文介绍了google.cloud.pubsub_v1.PublisherClient线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Cloud PubSub,并且想知道 google.cloud.pubsub_v1.PublisherClient 是否是线程安全的.我是否需要将此对象的新实例传递给每个 threading.Thread ,还是在线程之间共享同一实例安全吗?

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?

推荐答案

这取决于您使用的客户端库.

It depends on the client library you are using.

此Python客户端库不是线程安全的,因为它是基于httplib2构建的库,它不是线程安全的.但是,正如第一个链接所述,这是一个旧图书馆.用于Pub/Sub的较新的Python库是线程安全的.

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.

其他Google客户端库也是线程安全的". .NET一个例如,出于对约定的考虑,所有静态成员都应该是线程安全的.

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.

这篇关于google.cloud.pubsub_v1.PublisherClient线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆