File tree 2 files changed +9
-1
lines changed
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
1140
1140
pool, cpu_bound)
1141
1141
print('custom process pool', result)
1142
1142
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 >`.
1144
1150
1145
1151
This method returns a :class: `asyncio.Future ` object.
1146
1152
Original file line number Diff line number Diff line change @@ -2920,6 +2920,8 @@ Global variables
2920
2920
However, global variables which are just module level constants cause no
2921
2921
problems.
2922
2922
2923
+ .. _multiprocessing-safe-main-import :
2924
+
2923
2925
Safe importing of main module
2924
2926
2925
2927
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