Python多处理在传递数组参数时抛出错误

时间:2016-07-06 15:21:52

标签: python multiprocessing python-multithreading python-multiprocessing

我正在尝试设置一个单元测试工具,它启动一个使用python多处理并发运行的函数的几个实例。

我的主线程看起来像这样。函数new_instance()接受get_landing_pages()函数返回的对象。

如果我将一个简单的字符串作为参数传递,新进程就可以了。但是当我尝试传递lp对象时,我得到了很多错误。

if __name__ == '__main__':
    lp = get_landing_pages()
    p1 = Process(target=new_instance,args=(lp,))
    p1.start()
    p2 = Process(target=new_instance,args=(lp,))
    p2.start()
    p1.join()
    p2.join()

部分错误:

Traceback (most recent call last):
      File "C:\Users\cory_weiner\Desktop\dashboardErrorTool 6-30-2016.py", line 118, in <module>
        p1.start()
      File "C:\Python27\lib\multiprocessing\process.py", line 130, in start
        self._popen = Popen(self)
      File "C:\Python27\lib\multiprocessing\forking.py", line 277, in __init__
        dump(process_obj, to_child, HIGHEST_PROTOCOL)
      File "C:\Python27\lib\multiprocessing\forking.py", line 199, in dump
        ForkingPickler(file, protocol).dump(obj)
      File "C:\Python27\lib\pickle.py", line 224, in dump
        self.save(obj)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 554, in save_tuple
        save(element)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 606, in save_list
        self._batch_appends(iter(obj))
      File "C:\Python27\lib\pickle.py", line 639, in _batch_appends
        save(x)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce
        save(state)
      File "C:\Python27\lib\pickle.py", line 286, in save
        f(self, obj) # Call unbound method with explicit self
      File "C:\Python27\lib\pickle.py", line 655, in save_dict
        self._batch_setitems(obj.iteritems())
      File "C:\Python27\lib\pickle.py", line 687, in _batch_setitems
        save(v)
      File "C:\Python27\lib\pickle.py", line 331, in save
        self.save_reduce(obj=obj, *rv)
      File "C:\Python27\lib\pickle.py", line 425, in save_reduce

0 个答案:

没有答案