Skip to content

a small issue with the global_variable+pool approach when using Python 3.8 in macOS #335

@r-xue

Description

@r-xue

I just upgraded to Python 3.8 on a Mac and found that my previously working code (under 3.7) broke down, as well as the "Multiprocessing+global-variable" method presented at the end of this tutorial. It turns out Python 3.8 in macOS switches to the spawn start method in multiprocessing as default, so the resources of the parent process may not be inherited by the child process. Then the "global" variables become inaccessible.

A short workaround may be changing

from multiprocessing import Pool

into

import multiprocessing as mp
Pool = mp.get_context('fork').Pool

in the tutorial example. This is just to make sure that the fork method is always used.

This issue is not an emcee problem at all, and will only happen for certain Python versions + platforms. But the tutorial could be slightly tweaked for this.

btw, thank you for writing the excellent documentation for the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions