Python: Multiprocessing - Suds - _pickle.PicklingError: Can't pickle <class> attribute lookup failed
Python: Multiprocessing - Suds - _pickle.PicklingError: Can't pickle <class> attribute lookup failed
我正在建立 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
然后我有一个错误
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
我找不到解决此问题的方法。我该如何腌制这条线?
result_dict = self.setup(client)
是否可能存在其他决定?
谁能帮我?
这个错误是什么意思?
问题出在 setup
函数中。安装程序中的 Web 服务连接 ws
在 test
函数中使用。这就是为什么这个对象不能被腌制的原因。
如果您使用 multiprocessing
和 suds
或任何类似的库,则应在每个新进程中创建新连接。
我正在建立 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
然后我有一个错误
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
我找不到解决此问题的方法。我该如何腌制这条线?
result_dict = self.setup(client)
是否可能存在其他决定? 谁能帮我? 这个错误是什么意思?
问题出在 setup
函数中。安装程序中的 Web 服务连接 ws
在 test
函数中使用。这就是为什么这个对象不能被腌制的原因。
如果您使用 multiprocessing
和 suds
或任何类似的库,则应在每个新进程中创建新连接。