Kaydet (Commit) 83704963 authored tarafından Victor Stinner's avatar Victor Stinner

asyncio: add a note about (non) thread safety in each class

üst 532c69a4
...@@ -22,6 +22,8 @@ It provides multiple facilities, amongst which: ...@@ -22,6 +22,8 @@ It provides multiple facilities, amongst which:
Base class of event loops. Base class of event loops.
This class is :ref:`not thread safe <asyncio-multithreading>`.
Run an event loop Run an event loop
----------------- -----------------
...@@ -104,6 +106,9 @@ keywords to your callback, use :func:`functools.partial`. For example, ...@@ -104,6 +106,9 @@ keywords to your callback, use :func:`functools.partial`. For example,
Like :meth:`call_soon`, but thread safe. Like :meth:`call_soon`, but thread safe.
See the :ref:`concurrency and multithreading <asyncio-multithreading>`
section of the documentation.
.. _asyncio-delayed-calls: .. _asyncio-delayed-calls:
......
...@@ -23,6 +23,8 @@ then call the transport's methods for various purposes. ...@@ -23,6 +23,8 @@ then call the transport's methods for various purposes.
subprocess pipes. The methods available on a transport depend on subprocess pipes. The methods available on a transport depend on
the transport's kind. the transport's kind.
The transport classes are :ref:`not thread safe <asyncio-multithreading>`.
BaseTransport BaseTransport
------------- -------------
......
...@@ -31,6 +31,8 @@ Queue ...@@ -31,6 +31,8 @@ Queue
be interrupted between calling :meth:`qsize` and doing an operation on the be interrupted between calling :meth:`qsize` and doing an operation on the
Queue. Queue.
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. versionchanged:: 3.4.3 .. versionchanged:: 3.4.3
New :meth:`join` and :meth:`task_done` methods. New :meth:`join` and :meth:`task_done` methods.
......
...@@ -85,6 +85,8 @@ StreamReader ...@@ -85,6 +85,8 @@ StreamReader
.. class:: StreamReader(limit=None, loop=None) .. class:: StreamReader(limit=None, loop=None)
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. method:: exception() .. method:: exception()
Get the exception. Get the exception.
...@@ -155,6 +157,8 @@ StreamWriter ...@@ -155,6 +157,8 @@ StreamWriter
wait for flow control. It also adds a transport attribute which references wait for flow control. It also adds a transport attribute which references
the :class:`Transport` directly. the :class:`Transport` directly.
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. attribute:: transport .. attribute:: transport
Transport. Transport.
......
...@@ -193,6 +193,9 @@ Process ...@@ -193,6 +193,9 @@ Process
:meth:`~subprocess.Popen.wait` method of the :class:`~subprocess.Popen` :meth:`~subprocess.Popen.wait` method of the :class:`~subprocess.Popen`
class is implemented as a busy loop. 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() .. coroutinemethod:: wait()
Wait for child process to terminate. Set and return :attr:`returncode` Wait for child process to terminate. Set and return :attr:`returncode`
...@@ -310,6 +313,8 @@ are limits: ...@@ -310,6 +313,8 @@ are limits:
subprocesses from other threads. Call the :func:`get_child_watcher` subprocesses from other threads. Call the :func:`get_child_watcher`
function in the main thread to instantiate the child watcher. function in the main thread to instantiate the child watcher.
The :class:`asyncio.subprocess.Process` class is not thread safe.
.. seealso:: .. seealso::
The :ref:`Concurrency and multithreading in asyncio The :ref:`Concurrency and multithreading in asyncio
......
...@@ -209,6 +209,8 @@ Future ...@@ -209,6 +209,8 @@ Future
:func:`~concurrent.futures.as_completed` functions in the :func:`~concurrent.futures.as_completed` functions in the
:mod:`concurrent.futures` package. :mod:`concurrent.futures` package.
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. method:: cancel() .. method:: cancel()
Cancel the future and schedule callbacks. Cancel the future and schedule callbacks.
...@@ -375,6 +377,8 @@ Task ...@@ -375,6 +377,8 @@ Task
Don't directly create :class:`Task` instances: use the :func:`async` Don't directly create :class:`Task` instances: use the :func:`async`
function or the :meth:`BaseEventLoop.create_task` method. function or the :meth:`BaseEventLoop.create_task` method.
This class is :ref:`not thread safe <asyncio-multithreading>`.
.. classmethod:: all_tasks(loop=None) .. classmethod:: all_tasks(loop=None)
Return a set of all tasks for an event loop. Return a set of all tasks for an event loop.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment