[Python-checkins] cpython: asyncio doc: mention that asyncio is not thread-safe

victor.stinner python-checkins at python.org
Fri Feb 7 19:03:17 CET 2014


http://hg.python.org/cpython/rev/86bc4194f986
changeset:   89016:86bc4194f986
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Feb 07 19:03:05 2014 +0100
summary:
  asyncio doc: mention that asyncio is not thread-safe

files:
  Doc/library/asyncio-dev.rst |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst
--- a/Doc/library/asyncio-dev.rst
+++ b/Doc/library/asyncio-dev.rst
@@ -23,6 +23,12 @@
 
     loop.call_soon_threadsafe(asyncio.async, coro_func())
 
+Most asyncio objects are not thread safe. You should only worry if you access
+objects outside the event loop. For example, to cancel a future, don't call
+directly its :meth:`Future.cancel` method, but::
+
+    loop.call_soon_threadsafe(fut.cancel)
+
 To handle signals and to execute subprocesses, the event loop must be run in
 the main thread.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list