Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiprocessing issue with OSX+Py38 #2800

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions gensim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,11 @@ def run(self):
self.q.put(wrapped_chunk.pop(), block=True)


if os.name == 'nt':
# Multiprocessing on Windows (and on OSX with python3.8+) uses "spawn" mode, which
# causes issues with pickling.
# So for these two platforms, use simpler serial processing in `chunkize`.
# See https://github.com/RaRe-Technologies/gensim/pull/2800#discussion_r410890171
if os.name == 'nt' or (sys.platform == "darwin" and sys.version_info >= (3, 8)):
piskvorky marked this conversation as resolved.
Show resolved Hide resolved
def chunkize(corpus, chunksize, maxsize=0, as_numpy=False):
"""Split `corpus` into fixed-sized chunks, using :func:`~gensim.utils.chunkize_serial`.

Expand All @@ -1260,7 +1264,8 @@ def chunkize(corpus, chunksize, maxsize=0, as_numpy=False):

"""
if maxsize > 0:
warnings.warn("detected Windows; aliasing chunkize to chunkize_serial")
entity = "Windows" if os.name == 'nt' else "OSX with python3.8+"
warnings.warn("detected %s; aliasing chunkize to chunkize_serial" % entity)
for chunk in chunkize_serial(corpus, chunksize, as_numpy=as_numpy):
yield chunk
else:
Expand Down