File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1140,7 +1140,13 @@ Executing code in thread or process pools
11401140 pool, cpu_bound)
11411141 print('custom process pool', result)
11421142
1143- asyncio.run(main())
1143+ if __name__ == '__main__':
1144+ asyncio.run(main())
1145+
1146+ Note that the entry point guard (``if __name__ == '__main__' ``)
1147+ is required for option 3 due to the peculiarities of :mod: `multiprocessing `,
1148+ which is used by :class: `~concurrent.futures.ProcessPoolExecutor `.
1149+ See :ref: `Safe importing of main module <multiprocessing-safe-main-import >`.
11441150
11451151 This method returns a :class: `asyncio.Future ` object.
11461152
Original file line number Diff line number Diff line change @@ -2920,6 +2920,8 @@ Global variables
29202920 However, global variables which are just module level constants cause no
29212921 problems.
29222922
2923+ .. _multiprocessing-safe-main-import :
2924+
29232925Safe importing of main module
29242926
29252927 Make sure that the main module can be safely imported by a new Python
You can’t perform that action at this time.
0 commit comments