TypeError:预期的字符串或Unicode对象,找不到NoneType-多处理池在Zope / Plone外部方法中不起作用

时间:2018-11-27 16:45:01

标签: plone python-multiprocessing python-2.6 zope python-pool

我正在使用

Zope - 2.13.19
Python - 2.6.8

以下代码在手动运行时有效,但在外部方法中无效。 它引发以下错误。我在概念上做错了吗?

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/opt/python2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/opt/python2.6/lib/python2.6/threading.py", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/python2.6/lib/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks
    put(task)
TypeError: expected string or Unicode object, NoneType found


import time
from multiprocessing import Pool
import logging


def func(name):
    print 'hello %s,' % name
    time.sleep(5)
    print 'nice to meet you.'


def get_data():
    pool = Pool(processes=2)
    pool.map(func, ('frank', 'justin', 'osi', 'thomas'))

1 个答案:

答案 0 :(得分:0)

确保跨流程边界发送的所有内容都可以是pickled

Multimedia Mike所述:

  

“可以跨进程边界将对象发送给工作人员   只要对象可以被Python的pickle腌制   设施。”