我正在进行SOAP WSDL连接,然后我想在另一个procces中运行函数(线程不适合)
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)
是否可能存在其他决定? 谁能帮我? 这个错误意味着什么?
答案 0 :(得分:0)
setup
函数存在问题。设置中的Web服务连接ws
在test
函数中使用。这就是为什么这个物体不能发泡的原因。
如果您使用multiprocessing
和suds
或任何类似的lib,则应在每个新进程中创建新连接。