[英]Python: Multiprocessing - Suds - _pickle.PicklingError: Can't pickle <class> attribute lookup failed
I'm making SOAP WSDL connection and then I want to run function in another procces (threading is not suitable) 我正在建立SOAP WSDL连接,然后我想在另一个过程中运行函数(线程不适合)
from suds.client import Client
class dTest:
def setup(self, client):
ws = Client("http://localhost?wsdl")
# then I use some SOAP API methods and return dictionary with results
return result_dict
def test(self, name):
# in this function I use another SOAP API methods
return
def main(self, client):
result_dict = self.setup(client)
for name, num in result_dict.items():
p = multiprocessing.Process(target=self.test, args=[name])
p.start() # <- on this line I have an error
p.join(timeout)
if p.is_alive():
p.terminate
Then I have an error 然后我有一个错误
File "D:\IPWStest\test\dTest.py", line 318, in main
p.start()
File "C:\Python34\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Python34\lib\multiprocessing\context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Python34\lib\multiprocessing\context.py", line 313, in _Popen
return Popen(process_obj)
File "C:\Python34\lib\multiprocessing\popen_spawn_win32.py", line 66, in __init__
reduction.dump(process_obj, to_child)
File "C:\Python34\lib\multiprocessing\reduction.py", line 59, in dump
ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'suds.sudsobject.UserCredentialsType'>: attribute lookup UserCredentialsType on suds.sudsobject failed
I can't find any solution for this issue. 我找不到此问题的任何解决方案。 How can I pickle this line?
我如何腌制这条线?
result_dict = self.setup(client)
result_dict = self.setup(客户端)
Is another decision may be exist? 是否可能存在另一个决定? Can anyone help me?
谁能帮我? What does this error means?
此错误是什么意思?
Problem was in setup
function. 问题出在
setup
功能上。 Web-service connection ws
in setup uses in test
function. 网络服务连接
ws
在安装程序使用test
功能。 That's why this object cann't be pickle. 这就是为什么这个对象不能被腌制。 If you using
multiprocessing
and suds
or any similar lib, new connection should be created in every new process. 如果使用
multiprocessing
和suds
或任何类似的lib,则应在每个新进程中创建新连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.