TypeError: expected string or Unicode object, NoneType found - Multiprocessing Pool not working in Zope/Plone external methods

I'm using

Zope - 2.13.19
Python - 2.6.8

The below piece of code works when run manually but not when in External method. It throws the following error. Am I doing something conceptually wrong ?

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

1 Answers TypeError: expected string or Unicode object, NoneType found - Multiprocessing Pool not working in Zope/Plone external methods

Make sure all the things you're sending across process boundaries can be pickled.

As stated by Multimedia Mike:

"It is possible to send objects across process boundaries to worker processes as long as the objects can be pickled by Python's pickle facility."

4 months ago