Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2820a0

Browse files
miss-islingtonslateny
authored andcommitted
gh-85299: Add note warning about entry point guard for asyncio example (GH-93457)
(cherry picked from commit79fd6cc)Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
1 parentc6df6ee commita2820a0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎Doc/library/asyncio-eventloop.rst‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,13 @@ Executing code in thread or process pools
12061206
pool, cpu_bound)
12071207
print('custom process pool', result)
12081208

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

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

‎Doc/library/multiprocessing.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,6 +2955,8 @@ Global variables
29552955
However, global variables which are just module level constants cause no
29562956
problems.
29572957

2958+
.. _multiprocessing-safe-main-import:
2959+
29582960
Safe importing of main module
29592961

29602962
Make sure that the main module can be safely imported by a new Python

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp