diff options
author | Guido van Rossum <guido@python.org> | 2016-08-08 16:41:21 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-08-08 16:41:21 (GMT) |
commit | f68afd8544796e23115a6f25b008c153a1414aad (patch) | |
tree | a9e2cc246f138c40625d7dfa743fd059370f97ce /Doc/library/asyncio-dev.rst | |
parent | 08d85ee78d8bc69cefa627c309c2de51a97bc2b2 (diff) | |
download | cpython-f68afd8544796e23115a6f25b008c153a1414aad.zip cpython-f68afd8544796e23115a6f25b008c153a1414aad.tar.gz cpython-f68afd8544796e23115a6f25b008c153a1414aad.tar.bz2 |
Issue #27700: Document AbstractEventLoop, not BaseEventLoop.
Diffstat (limited to 'Doc/library/asyncio-dev.rst')
-rw-r--r-- | Doc/library/asyncio-dev.rst | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst index b9557af..e9ec638 100644 --- a/Doc/library/asyncio-dev.rst +++ b/Doc/library/asyncio-dev.rst @@ -21,7 +21,7 @@ enable *debug mode*. To enable all debug checks for an application: * Enable the asyncio debug mode globally by setting the environment variable - :envvar:`PYTHONASYNCIODEBUG` to ``1``, or by calling :meth:`BaseEventLoop.set_debug`. + :envvar:`PYTHONASYNCIODEBUG` to ``1``, or by calling :meth:`AbstractEventLoop.set_debug`. * Set the log level of the :ref:`asyncio logger <asyncio-logger>` to :py:data:`logging.DEBUG`. For example, call ``logging.basicConfig(level=logging.DEBUG)`` at startup. @@ -33,18 +33,18 @@ Examples debug checks: * Log :ref:`coroutines defined but never "yielded from" <asyncio-coroutine-not-scheduled>` -* :meth:`~BaseEventLoop.call_soon` and :meth:`~BaseEventLoop.call_at` methods +* :meth:`~AbstractEventLoop.call_soon` and :meth:`~AbstractEventLoop.call_at` methods raise an exception if they are called from the wrong thread. * Log the execution time of the selector * Log callbacks taking more than 100 ms to be executed. The - :attr:`BaseEventLoop.slow_callback_duration` attribute is the minimum + :attr:`AbstractEventLoop.slow_callback_duration` attribute is the minimum duration in seconds of "slow" callbacks. * :exc:`ResourceWarning` warnings are emitted when transports and event loops are :ref:`not closed explicitly <asyncio-close-transports>`. .. seealso:: - The :meth:`BaseEventLoop.set_debug` method and the :ref:`asyncio logger + The :meth:`AbstractEventLoop.set_debug` method and the :ref:`asyncio logger <asyncio-logger>`. @@ -68,7 +68,7 @@ For example, write:: Don't schedule directly a call to the :meth:`~Future.set_result` or the :meth:`~Future.set_exception` method of a future with -:meth:`BaseEventLoop.call_soon`: the future can be cancelled before its method +:meth:`AbstractEventLoop.call_soon`: the future can be cancelled before its method is called. If you wait for a future, you should check early if the future was cancelled to @@ -96,7 +96,7 @@ the same thread. But when the task uses ``yield from``, the task is suspended and the event loop executes the next task. To schedule a callback from a different thread, the -:meth:`BaseEventLoop.call_soon_threadsafe` method should be used. Example:: +:meth:`AbstractEventLoop.call_soon_threadsafe` method should be used. Example:: loop.call_soon_threadsafe(callback, *args) @@ -116,7 +116,7 @@ To schedule a coroutine object from a different thread, the 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 +The :meth:`AbstractEventLoop.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. @@ -145,7 +145,7 @@ APIs like :ref:`protocols <asyncio-protocol>`. An executor can be used to run a task in a different thread or even in a different process, to not block the thread of the event loop. See the -:meth:`BaseEventLoop.run_in_executor` method. +:meth:`AbstractEventLoop.run_in_executor` method. .. seealso:: @@ -168,7 +168,7 @@ Detect coroutine objects never scheduled ---------------------------------------- When a coroutine function is called and its result is not passed to -:func:`ensure_future` or to the :meth:`BaseEventLoop.create_task` method, +:func:`ensure_future` or to the :meth:`AbstractEventLoop.create_task` method, the execution of the coroutine object will never be scheduled which is probably a bug. :ref:`Enable the debug mode of asyncio <asyncio-debug-mode>` to :ref:`log a warning <asyncio-logger>` to detect it. @@ -191,7 +191,7 @@ Output in debug mode:: test() The fix is to call the :func:`ensure_future` function or the -:meth:`BaseEventLoop.create_task` method with the coroutine object. +:meth:`AbstractEventLoop.create_task` method with the coroutine object. .. seealso:: @@ -267,7 +267,7 @@ coroutine in another coroutine and use classic try/except:: loop.run_forever() loop.close() -Another option is to use the :meth:`BaseEventLoop.run_until_complete` +Another option is to use the :meth:`AbstractEventLoop.run_until_complete` function:: task = asyncio.ensure_future(bug()) |