asyncio: add a note about (non) thread safety in each class
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Feb 2015 13:24:15 +0000 (14:24 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 25 Feb 2015 13:24:15 +0000 (14:24 +0100)
Doc/library/asyncio-eventloop.rst
Doc/library/asyncio-protocol.rst
Doc/library/asyncio-queue.rst
Doc/library/asyncio-stream.rst
Doc/library/asyncio-subprocess.rst
Doc/library/asyncio-task.rst

index f2c894569b0e046910683fdb74cb01a5b5efea31..d27eb4bd8289edaeb0c2b6cba90ec7a46de31751 100644 (file)
@@ -22,6 +22,8 @@ It provides multiple facilities, amongst which:
 
    Base class of event loops.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
 Run an event loop
 -----------------
 
@@ -104,6 +106,9 @@ keywords to your callback, use :func:`functools.partial`. For example,
 
    Like :meth:`call_soon`, but thread safe.
 
+   See the :ref:`concurrency and multithreading <asyncio-multithreading>`
+   section of the documentation.
+
 
 .. _asyncio-delayed-calls:
 
index b6fcc4840b562fd6c5788a188ffed15cf8d94885..2e671e89a285b2b879cb64268e9d7a2c1bc61b0c 100644 (file)
@@ -23,6 +23,8 @@ then call the transport's methods for various purposes.
 subprocess pipes.  The methods available on a transport depend on
 the transport's kind.
 
+The transport classes are :ref:`not thread safe <asyncio-multithreading>`.
+
 
 BaseTransport
 -------------
index 19957a0bf9f77a9a5943a9da3d32bd24fb18ac38..c82e08b105be033157d131e3b841873595928d8d 100644 (file)
@@ -31,6 +31,8 @@ Queue
    be interrupted between calling :meth:`qsize` and doing an operation on the
    Queue.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
    .. versionchanged:: 3.4.3
       New :meth:`join` and :meth:`task_done` methods.
 
index 22b7341cb70280867bf0a388a5928fb080a0f1ef..41b24acaaf9482d6f0bddeb6c9cead03f08bc458 100644 (file)
@@ -85,6 +85,8 @@ StreamReader
 
 .. class:: StreamReader(limit=None, loop=None)
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
    .. method:: exception()
 
       Get the exception.
@@ -155,6 +157,8 @@ StreamWriter
    wait for flow control.  It also adds a transport attribute which references
    the :class:`Transport` directly.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
    .. attribute:: transport
 
       Transport.
index 1334f5b133b25fb34fdda713134c40ba5a98187e..1b8203047af00067e8754df23ff7c19e4e06ad60 100644 (file)
@@ -193,6 +193,9 @@ Process
      :meth:`~subprocess.Popen.wait` method of the :class:`~subprocess.Popen`
      class is implemented as a busy loop.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`. See also the
+   :ref:`Subprocess and threads <asyncio-subprocess-threads>` section.
+
    .. coroutinemethod:: wait()
 
       Wait for child process to terminate.  Set and return :attr:`returncode`
@@ -310,6 +313,8 @@ are limits:
   subprocesses from other threads. Call the :func:`get_child_watcher`
   function in the main thread to instantiate the child watcher.
 
+The :class:`asyncio.subprocess.Process` class is not thread safe.
+
 .. seealso::
 
    The :ref:`Concurrency and multithreading in asyncio
index edc05c3d6ac52f355fae869a56758db75d047f8d..158a0d87842cd03f892f68efedfd7b6880078ab0 100644 (file)
@@ -209,6 +209,8 @@ Future
      :func:`~concurrent.futures.as_completed` functions in the
      :mod:`concurrent.futures` package.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
    .. method:: cancel()
 
       Cancel the future and schedule callbacks.
@@ -375,6 +377,8 @@ Task
    Don't directly create :class:`Task` instances: use the :func:`async`
    function or the :meth:`BaseEventLoop.create_task` method.
 
+   This class is :ref:`not thread safe <asyncio-multithreading>`.
+
    .. classmethod:: all_tasks(loop=None)
 
       Return a set of all tasks for an event loop.