在 python 中使用 Suds for SOAP,suds.client.Client 对象线程安全吗?
我正在使用 Suds 从 python 访问 SOAP Web 服务。如果我有多个 threading.Thread 执行线程,每个线程是否可以同时安全地访问同一个 suds.client.Client 实例,或者我必须为每个线程创建单独的 Client 对象?
I'm using Suds to access a SOAP web service from python. If I have multiple threading.Thread threads of execution, can each of them safely access the same suds.client.Client instance concurrently, or must I create separate Client objects for each thread?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知它们不是线程安全的。只要您使用队列或线程池,您就可以安全地使用相同的客户端对象。这样,当一个线程处理完客户端后,下一个线程就可以使用它。
然而,对于基于网络的活动,您可能应该问自己哪个更好。线程还是异步网络编程?最近有一个向 SUDS 提议的补丁,以支持异步套接字与基于事件的使用诸如 Twisted、greenlet 等软件包
As far as I know they are NOT thread safe. You could safely use the same client object so long as you are using a queue or thread pool. That way when one thread is done with the client, the next one can use it.
For network-based events however, you should probably ask yourself which is better. Threading or asynchronous network programming? There was recently a patch proposed to SUDS to enable support for asynch sockets for use with event-based packages such as Twisted, greenlets, etc.