This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Multi-processing example inaccurate warning
Type: Stage:
Components: Documentation Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: anthony-flury, docs@python, xtreak
Priority: normal Keywords:

Created on 2018-10-04 10:40 by anthony-flury, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg327046 - (view) Author: Anthony Flury (anthony-flury) * Date: 2018-10-04 10:40
On the Multi-processing page <> (just above the reference section) there is a warning that the examples wont work from the interpreter.

This is not entirely accurate in that the examples do work, in the interpreter within Linux (and Mac OS I think), where the O/S supports processes being forked.

In fact it is only in Windows, where a brand new process needs to be started and the source is effectively re-imported is there an issue running the examples in the interpreter.

Should the documentation make this clearer ?
msg327049 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-10-04 12:02
Thanks for the report. Are you referring to the below warning?

> Functionality within this package requires that the __main__ module be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.pool.Pool examples will not work in the interactive interpreter. For example:

I tried the example and it throws the AttributeError as shown in the example in Linux and MacOS. Maybe I am wrong on the above. Can you please add in the specific example that is shown as not executable from the interpreter but actually works?

msg327238 - (view) Author: Anthony Flury (anthony-flury) * Date: 2018-10-06 09:05
An example that does work : 

    $ python3

      Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
      [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
      Type "help", "copyright", "credits" or "license" for more information.

      >>> from multiprocessing import Pool
      >>> def f(x): 
      ...     return x**2
      >>> with Pool(10) as p:
      ...     print(, range(1,10)))
      [1, 4, 9, 16, 25, 36, 49, 64, 81]

So something about having Pool as a context manager means it works - very odd then.

BTW - with the exception of the example saying 'don't do this it doesn't work', none of the examples on the page are shown on the command line interpreter; but the first example uses a Pool context manager - which works as above.
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79072
2018-10-06 09:05:47anthony-flurysetmessages: + msg327238
2018-10-04 12:02:08xtreaksetnosy: + xtreak
messages: + msg327049
2018-10-04 10:40:06anthony-flurycreate