简体   繁体   English

Python:多重处理-肥皂水-_pickle.PicklingError:无法腌制 <class> 属性查找失败

[英]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. 如果使用multiprocessingsuds或任何类似的lib,则应在每个新进程中创建新连接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pickle.PicklingError:不能腌制 <class 'module'> :内建属性查找模块失败 - pickle.PicklingError: Can't pickle <class 'module'>: attribute lookup module on builtins failed Python多处理pickle.PicklingError:无法腌制&#39;_subprocess_handle&#39; - Python multiprocessing pickle.PicklingError: Can't pickle '_subprocess_handle' nltk.tag.hmm上的Python HMM标记器_pickle.PicklingError属性查找估计器失败 - Python HMM tagger _pickle.PicklingError attribute lookup estimator on nltk.tag.hmm failed 错误:_pickle.PicklingError:不能腌制<function <lambda>在 0x0000002F2175B048&gt;:属性查找<lambda>在 __main__ 上失败 - Error :_pickle.PicklingError: Can't pickle <function <lambda> at 0x0000002F2175B048>: attribute lookup <lambda> on __main__ failed pickle.PicklingError: 不能腌制<function past_match_sim at 0x7fa26e03b7b8> : __main__ 上的属性查找 past_match_sim 失败</function> - pickle.PicklingError: Can't pickle <function past_match_sim at 0x7fa26e03b7b8>: attribute lookup past_match_sim on __main__ failed PicklingError:无法腌制 <type 'function'> :属性查找__builtin __。function失败(多处理) - PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed (multiprocessing) PicklingError:无法腌制 <class 'module'> :内建属性查找模块失败 - PicklingError: Can't pickle <class 'module'>: attribute lookup module on builtins failed pickle.PicklingError: Can't pickle: 它与 object 不同 - pickle.PicklingError: Can't pickle: it's not the same object as multiprocessing.Pool - PicklingError:不能腌制<type 'thread.lock'> : 属性查找 thread.lock 失败 - multiprocessing.Pool - PicklingError: Can't pickle <type 'thread.lock'>: attribute lookup thread.lock failed 事件处理程序中的Python Kivy PicklingError:无法腌制 <type 'code'> :属性查找__builtin __。code失败 - Python Kivy PicklingError within event handler: Can't pickle <type 'code'>: attribute lookup __builtin__.code failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM