]> granicus.if.org Git - python/commitdiff
Docs and one small improvement for issue #25304, by Vincent Michel. (Merge 3.4->3.5.)
authorGuido van Rossum <guido@python.org>
Mon, 5 Oct 2015 23:23:13 +0000 (16:23 -0700)
committerGuido van Rossum <guido@python.org>
Mon, 5 Oct 2015 23:23:13 +0000 (16:23 -0700)
1  2 
Doc/library/asyncio-dev.rst
Doc/library/asyncio-task.rst

index 48e7666bbb626b78fb7b08ae6441708e2d80a19b,1d1f79529408c661d9780d488119680f274c8762..156c5c06ac2622e64ae596fd12ec26beaed7c40c
@@@ -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 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
  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.
Simple merge