gpt4 book ai didi

plone - TypeError : expected string or Unicode object, NoneType found - 多处理池在 Zope/Plone 外部方法中不起作用

转载 作者:行者123 更新时间:2023-12-04 12:56:47 25 4
gpt4 key购买 nike

我正在使用

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'))

最佳答案

确保您跨进程边界发送的所有内容都可以是 pickled .
正如 Multimedia Mike 所述:

It is possible to send objects across process boundaries to workerprocesses as long as the objects can be pickled by Python's picklefacility.

关于plone - TypeError : expected string or Unicode object, NoneType found - 多处理池在 Zope/Plone 外部方法中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53504351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com