Skip to content

multiprocessing.pool.MaybeEncodingError with Python 3.11/Apple Silicon using Pool.starmap() #102205

@zopyx

Description

@zopyx

I have this small script

https://github.com/zopyx/print-css-rocks/blob/master/lessons/generate_all.py

on Python 3.11

Python 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

which generates some PDFs and Images using a processor pool. The script works fine on various Linux system
but fails in a reproducible way on Mac M1.

The cannot pickle message does not make much sense since the return value from the execute() method is just a simple dict with some strings - no difference between Mac and Linux.

Traceback (most recent call last):
  File "/Users/ajung/src/print-css-rocks/lessons/generate_all.py", line 169, in <module>
    main()
  File "/Users/ajung/src/print-css-rocks/lessons/generate_all.py", line 144, in main
    result = pool.starmap(process_target, jobs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", line 375, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/pool.py", line 774, in get
    raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x1060dd510>'. Reason: 'TypeError("cannot pickle '_io.BufferedRandom' object")'

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions