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 @@ -1206,7 +1206,13 @@ Executing code in thread or process pools
1206
1206
pool, cpu_bound)
1207
1207
print('custom process pool', result)
1208
1208
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 >`.
1210
1216
1211
1217
This method returns a :class: `asyncio.Future ` object.
1212
1218
Original file line number Diff line number Diff line change @@ -2955,6 +2955,8 @@ Global variables
2955
2955
However, global variables which are just module level constants cause no
2956
2956
problems.
2957
2957
2958
+ .. _multiprocessing-safe-main-import :
2959
+
2958
2960
Safe importing of main module
2959
2961
2960
2962
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