From: Victor Stinner Date: Fri, 7 Feb 2014 18:03:05 +0000 (+0100) Subject: asyncio doc: mention that asyncio is not thread-safe X-Git-Tag: v3.4.0rc1~55 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=790202d61308efd3e7bc69cd61bff2306d789e57;p=thirdparty%2FPython%2Fcpython.git asyncio doc: mention that asyncio is not thread-safe --- diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst index 686e49605315..aab925b1e535 100644 --- a/Doc/library/asyncio-dev.rst +++ b/Doc/library/asyncio-dev.rst @@ -23,6 +23,12 @@ schedule a coroutine from a different thread:: 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.