Improve asyncio.loop.call_soon() documentation (GH-20883)

* Add a glossary entry for the term "callback"
* Link to it in loop.call_soon() and in the "Concurrency and Multithreading" section

Co-authored-by: Kyle Stanley <aeros167@gmail.com>
This commit is contained in:
Roger Iyengar 2020-06-22 22:16:00 -04:00 committed by GitHub
parent c96d00e88e
commit a16d697049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -189,6 +189,10 @@ Glossary
A list of bytecode instructions can be found in the documentation for A list of bytecode instructions can be found in the documentation for
:ref:`the dis module <bytecodes>`. :ref:`the dis module <bytecodes>`.
callback
A subroutine function which is passed as an argument to be executed at
some point in the future.
class class
A template for creating user-defined objects. Class definitions A template for creating user-defined objects. Class definitions
normally contain method definitions which operate on instances of the normally contain method definitions which operate on instances of the

View File

@ -73,7 +73,7 @@ event loop, no other Tasks can run in the same thread. When a Task
executes an ``await`` expression, the running Task gets suspended, and executes an ``await`` expression, the running Task gets suspended, and
the event loop executes the next Task. the event loop executes the next Task.
To schedule a callback from a different OS thread, the To schedule a :term:`callback` from another OS thread, the
:meth:`loop.call_soon_threadsafe` method should be used. Example:: :meth:`loop.call_soon_threadsafe` method should be used. Example::
loop.call_soon_threadsafe(callback, *args) loop.call_soon_threadsafe(callback, *args)

View File

@ -191,8 +191,8 @@ Scheduling callbacks
.. method:: loop.call_soon(callback, *args, context=None) .. method:: loop.call_soon(callback, *args, context=None)
Schedule a *callback* to be called with *args* arguments at Schedule the *callback* :term:`callback` to be called with
the next iteration of the event loop. *args* arguments at the next iteration of the event loop.
Callbacks are called in the order in which they are registered. Callbacks are called in the order in which they are registered.
Each callback will be called exactly once. Each callback will be called exactly once.