mirror of
https://github.com/python/cpython
synced 2024-10-14 18:16:02 +00:00
gh-85299: Add note warning about entry point guard for asyncio example (#93457)
This commit is contained in:
parent
35fa5d5e7f
commit
79fd6ccdbe
|
@ -1253,7 +1253,13 @@ Executing code in thread or process pools
|
||||||
pool, cpu_bound)
|
pool, cpu_bound)
|
||||||
print('custom process pool', result)
|
print('custom process pool', result)
|
||||||
|
|
||||||
asyncio.run(main())
|
if __name__ == '__main__':
|
||||||
|
asyncio.run(main())
|
||||||
|
|
||||||
|
Note that the entry point guard (``if __name__ == '__main__'``)
|
||||||
|
is required for option 3 due to the peculiarities of :mod:`multiprocessing`,
|
||||||
|
which is used by :class:`~concurrent.futures.ProcessPoolExecutor`.
|
||||||
|
See :ref:`Safe importing of main module <multiprocessing-safe-main-import>`.
|
||||||
|
|
||||||
This method returns a :class:`asyncio.Future` object.
|
This method returns a :class:`asyncio.Future` object.
|
||||||
|
|
||||||
|
|
|
@ -2954,6 +2954,8 @@ Global variables
|
||||||
However, global variables which are just module level constants cause no
|
However, global variables which are just module level constants cause no
|
||||||
problems.
|
problems.
|
||||||
|
|
||||||
|
.. _multiprocessing-safe-main-import:
|
||||||
|
|
||||||
Safe importing of main module
|
Safe importing of main module
|
||||||
|
|
||||||
Make sure that the main module can be safely imported by a new Python
|
Make sure that the main module can be safely imported by a new Python
|
||||||
|
|
Loading…
Reference in a new issue