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 @@ -1253,7 +1253,13 @@ Executing code in thread or process pools
1253
1253
pool, cpu_bound)
1254
1254
print('custom process pool', result)
1255
1255
1256
- asyncio.run(main())
1256
+ if __name__ == '__main__':
1257
+ asyncio.run(main())
1258
+
1259
+ Note that the entry point guard (``if __name__ == '__main__' ``)
1260
+ is required for option 3 due to the peculiarities of :mod: `multiprocessing `,
1261
+ which is used by :class: `~concurrent.futures.ProcessPoolExecutor `.
1262
+ See :ref: `Safe importing of main module <multiprocessing-safe-main-import >`.
1257
1263
1258
1264
This method returns a :class: `asyncio.Future ` object.
1259
1265
Original file line number Diff line number Diff line change @@ -2954,6 +2954,8 @@ Global variables
2954
2954
However, global variables which are just module level constants cause no
2955
2955
problems.
2956
2956
2957
+ .. _multiprocessing-safe-main-import :
2958
+
2957
2959
Safe importing of main module
2958
2960
2959
2961
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