Skip to content

Commit 0faf6cb

Browse files
author
Tyler Goodlet
committed
Document result_callback arg
1 parent 6b296c2 commit 0faf6cb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

docs/index.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,20 +706,33 @@ using the :py:meth:`pluggy._HookCaller.call_historic()` method:
706706

707707
.. code-block:: python
708708
709+
def callback(result):
710+
print("historic call result is {result}".format(result=result))
711+
709712
# call with history; no results returned
710-
pm.hook.myhook.call_historic(config=config, args=sys.argv)
713+
pm.hook.myhook.call_historic(
714+
config=config, args=sys.argv,
715+
result_callback=callback
716+
)
711717
712718
# ... more of our program ...
713719
714720
# late loading of some plugin
715721
import mylateplugin
716722
717-
# historic call back is done here
723+
# historic callback is invoked here
718724
pm.register(mylateplugin)
719725
720726
Note that if you ``call_historic()`` the ``_HookCaller`` (and thus your
721727
calling code) can not receive results back from the underlying *hookimpl*
722-
functions.
728+
functions. Instead you can provide a *callback* for processing results
729+
(like the ``callback`` function above) which will be called as each
730+
new plugin is registered.
731+
732+
.. note::
733+
*historic* calls are incompatible with :ref:`firstresult` marked
734+
hooks since only the first registered plugin's hook(s) would
735+
ever be called.
723736

724737
Calling with extras
725738
-------------------

0 commit comments

Comments
 (0)