Skip to content

gh-85299: Add note warning about entry point guard for asyncio example #93457

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

Merged
merged 5 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,13 @@ Executing code in thread or process pools
pool, cpu_bound)
print('custom process pool', result)

asyncio.run(main())
if __name__ == '__main__':
asyncio.run(main())

Note that the entry point guard (``if __name__ == '__main__'``)
is required for option 3 due to the peculiarities of :mod:`multiprocessing`,
which is used by :class:`~concurrent.futures.ProcessPoolExecutor`.
See :ref:`Safe importing of main module <multiprocessing-safe-main-import>`.

This method returns a :class:`asyncio.Future` object.

Expand Down
2 changes: 2 additions & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,8 @@ Global variables
However, global variables which are just module level constants cause no
problems.

.. _multiprocessing-safe-main-import:

Safe importing of main module

Make sure that the main module can be safely imported by a new Python
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy