diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-28 12:15:41 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-28 12:15:41 (GMT) |
commit | 8464c24c82f3fc0d15afe85f86ac6b0ccd3e65d3 (patch) | |
tree | 990918116cecd94f9104bf2fadc46cfa5d4956a2 /Doc/library/asyncio-task.rst | |
parent | 25c7d3fb2125f964fe5b9317b31de39117072150 (diff) | |
download | cpython-8464c24c82f3fc0d15afe85f86ac6b0ccd3e65d3.zip cpython-8464c24c82f3fc0d15afe85f86ac6b0ccd3e65d3.tar.gz cpython-8464c24c82f3fc0d15afe85f86ac6b0ccd3e65d3.tar.bz2 |
asyncio doc: explain how to pass keywords to callbacks (functools.partial)
Diffstat (limited to 'Doc/library/asyncio-task.rst')
-rw-r--r-- | Doc/library/asyncio-task.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 21c4e33..a07db29 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -253,6 +253,11 @@ Future future is already done when this is called, the callback is scheduled with :meth:`~BaseEventLoop.call_soon`. + :ref:`Use functools.partial to pass parameters to the callback + <asyncio-pass-keywords>`. For example, + ``fut.add_done_callback(functools.partial(print, "Future:", + flush=True))`` will call ``print("Future:", fut, flush=True)``. + .. method:: remove_done_callback(fn) Remove all instances of a callback from the "call when done" list. |