summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-09-04 22:30:21 (GMT)
committerGitHub <noreply@github.com>2020-09-04 22:30:21 (GMT)
commit4ddb2d73ac661af516a252fe697ec05e726b0f20 (patch)
tree64752c4d7c9eba1f0370786fcea8b4567659b85c /Doc
parente77547b90cb3b819113c722579a7fc070de0c2ca (diff)
downloadcpython-4ddb2d73ac661af516a252fe697ec05e726b0f20.zip
cpython-4ddb2d73ac661af516a252fe697ec05e726b0f20.tar.gz
cpython-4ddb2d73ac661af516a252fe697ec05e726b0f20.tar.bz2
[3.8] Improve asyncio-dev 'Concurrency and Multithreading' docs (GH-20882) (GH-22010)
I added some information to the `Concurrency and Multithreading` section of the `Developing with asyncio` guide. This is all information that would have helped me when I started using asyncio. I incorrectly assumed that `loop.call_soon_threadsafe()` and `run_coroutine_threadsafe()` could be called from a thread in a process separate from the one that the event loop is running in. Explicitly stating that this will not work will probably help some people starting out with asyncio in the future. I also added references to some other functions that can be used for inter-process communication without blocking the event loop. The section already mentions running blocking code in a ThreadPoolExecutor, but I think listing these other options in this section will also be helpful. (cherry picked from commit c68c5af2dc5ada8875a662f2beaac6234eae2a5a) Co-authored-by: Roger Iyengar <ri@rogeriyengar.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/asyncio-dev.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst
index 0d302ea..d7ed962 100644
--- a/Doc/library/asyncio-dev.rst
+++ b/Doc/library/asyncio-dev.rst
@@ -107,6 +107,16 @@ The :meth:`loop.run_in_executor` method can be used with a
blocking code in a different OS thread without blocking the OS thread
that the event loop runs in.
+There is currently no way to schedule coroutines or callbacks directly
+from a different process (such as one started with
+:mod:`multiprocessing`). The :ref:`Event Loop Methods <asyncio-event-loop>`
+section lists APIs that can read from pipes and watch file descriptors
+without blocking the event loop. In addition, asyncio's
+:ref:`Subprocess <asyncio-subprocess>` APIs provide a way to start a
+process and communicate with it from the event loop. Lastly, the
+aforementioned :meth:`loop.run_in_executor` method can also be used
+with a :class:`concurrent.futures.ProcessPoolExecutor` to execute
+code in a different process.
.. _asyncio-handle-blocking: