mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
asyncio doc: explain how to pass keywords to callbacks (functools.partial)
This commit is contained in:
parent
25c7d3fb21
commit
8464c24c82
2 changed files with 38 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue