File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -706,20 +706,33 @@ using the :py:meth:`pluggy._HookCaller.call_historic()` method:
706
706
707
707
.. code-block :: python
708
708
709
+ def callback (result ):
710
+ print (" historic call result is {result} " .format(result = result))
711
+
709
712
# 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
+ )
711
717
712
718
# ... more of our program ...
713
719
714
720
# late loading of some plugin
715
721
import mylateplugin
716
722
717
- # historic call back is done here
723
+ # historic callback is invoked here
718
724
pm.register(mylateplugin)
719
725
720
726
Note that if you ``call_historic() `` the ``_HookCaller `` (and thus your
721
727
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.
723
736
724
737
Calling with extras
725
738
-------------------
You can’t perform that action at this time.
0 commit comments