osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about Multi-processing


On Wed, Oct 3, 2018 at 2:13 AM Anthony Flury via Python-list
<python-list at python.org> wrote:
> I continued to read the documentation and came to this quote :
>
>     /Functionality within this package requires that the
>     //|__main__|//module be importable by the children. This is covered
>     in //Programming guidelines
>     <https://docs.python.org/3/library/multiprocessing.html?highlight=process#multiprocessing-programming>//however
>     it is worth pointing out here. This means that some examples, such
>     as the //|multiprocessing.pool.Pool|
>     <https://docs.python.org/3/library/multiprocessing.html?highlight=process#multiprocessing.pool.Pool>//examples
>     will not work in the interactive interpreter./
>
> The Documentation then gives a clear example very similar to mine :
>
> But when I run this exact example in the command line interpreter it
> works fine :
>
> Is the documentation wrong ? is something weird going on ?
>

You're running it on Linux, and it can fork to create child processes.
If you were to run that on Windows, where forking isn't an option[1],
the creation of child processes would involve spinning up a new Python
process, importing main, and invoking the appropriate function from
there.

ChrisA
[1] AIUI, forking technically is possible on Windows, but it's not the
way things are done