From: Guido van Rossum Date: Mon, 5 Oct 2015 23:23:13 +0000 (-0700) Subject: Docs and one small improvement for issue #25304, by Vincent Michel. (Merge 3.4->3.5.) X-Git-Tag: v3.5.1rc1~210 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5db034acfaa79447cb5c310f6ad7071737474027;p=python Docs and one small improvement for issue #25304, by Vincent Michel. (Merge 3.4->3.5.) --- 5db034acfaa79447cb5c310f6ad7071737474027 diff --cc Doc/library/asyncio-dev.rst index 48e7666bbb,1d1f795294..156c5c06ac --- a/Doc/library/asyncio-dev.rst +++ b/Doc/library/asyncio-dev.rst @@@ -107,9 -106,16 +106,16 @@@ directly its :meth:`Future.cancel` meth loop.call_soon_threadsafe(fut.cancel) +To handle signals and to execute subprocesses, the event loop must be run in +the main thread. + + To schedule a coroutine object from a different thread, the + :func:`run_coroutine_threadsafe` function should be used. It returns a + :class:`concurrent.futures.Future` to access the result:: + + future = asyncio.run_coroutine_threadsafe(coro_func(), loop) + result = future.result(timeout) # Wait for the result with a timeout + -To handle signals and to execute subprocesses, the event loop must be run in -the main thread. - The :meth:`BaseEventLoop.run_in_executor` method can be used with a thread pool executor to execute a callback in different thread to not block the thread of the event loop.