Я пишу многопроцессорную логику. Тот же фрагмент кода прекрасно работает в моей локальной среде, в то время как он генерирует исключение 'cPickle.PicklingError: Can't pickle: поиск атрибута встроенный .function fail' в моем док-контейнере ubuntu16.04.
Моя локальная среда с miniconda python2.7.12 env.
Контейнер Docker с Ubuntu: образ 16.04 и установленный python-dev.
Тот же код, что и:
from pathos.multiprocessing import ProcessPool as Pool
# from multiprocessing import Pool
from functools import partial
class PreProcessor():
def __init__(self):
content_list = range(6)
mock_predict_field_partial = partial(self.mock_preprocess, 'output')
pool = Pool(4)
features = pool.map(mock_predict_field_partial, content_list)
print(features)
@staticmethod
def mock_preprocess(_output_dir, content):
return 'hello {}'.format(content)
if __name__ == '__main__':
PreProcessor()
Контейнер Docker устанавливает все с помощью следующих команд:
apt-get update
apt-get install -y build-essential
apt-get install -y python-dev
apt-get install -y curl
apt-get install -y git
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
pip install pathos
Мне интересно, как я могу правильно настроить многопроцессорную логику в моем док-контейнере.