Skip to content

Fix a traceback in multiprocessing example #100408

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

Closed
serhiy-storchaka opened this issue Dec 21, 2022 · 2 comments
Closed

Fix a traceback in multiprocessing example #100408

serhiy-storchaka opened this issue Dec 21, 2022 · 2 comments
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Dec 21, 2022

The multiprocessing module documentation contains the following example:

      >>> from multiprocessing import Pool
      >>> p = Pool(5)
      >>> def f(x):
      ...     return x*x
      ...
      >>> with p:
      ...   p.map(f, [1,2,3])
      Process PoolWorker-1:
      Process PoolWorker-2:
      Process PoolWorker-3:
      Traceback (most recent call last):
      Traceback (most recent call last):
      Traceback (most recent call last):
      AttributeError: 'module' object has no attribute 'f'
      AttributeError: 'module' object has no attribute 'f'
      AttributeError: 'module' object has no attribute 'f'

Actually, it is outdated. It was so in Python 2, but in Python 3 before 3.12 you get AttributeError with different message

AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>

and in 3.12 you get

AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error docs Documentation in the Doc dir 3.11 only security fixes 3.10 only security fixes 3.12 only security fixes labels Dec 21, 2022
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Dec 21, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 5, 2023
@erlend-aasland
Copy link
Contributor

It seems to me we can close this issue as completed.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 29, 2023
@serhiy-storchaka
Copy link
Member Author

The fix was not backported to 3.11 yet.

serhiy-storchaka added a commit that referenced this issue Jun 29, 2023
…) (GH-106231)

(cherry picked from commit a28d4ed)

Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

2 participants