Files
palladum-lightning/tests/plugins/dep_a.py
Rusty Russell a4f772efa7 lightningd: avoid race when runtime-added plugins register hooks.
If we add a new hook, not at the end, while hooks are getting called,
then iteration could be messed up (e.g. calling a plugin twice, or
skipping one).

The simplest thing is to defer updates until nobody is calling the
hook.  In theory this could livelock, in practice it won't.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30

19 lines
338 B
Python
Executable File

#!/usr/bin/env python3
from pyln.client import Plugin
import time
"""A simple plugin that must come before dep_b.
"""
plugin = Plugin()
@plugin.hook('htlc_accepted', before=['dep_b.py'])
def on_htlc_accepted(htlc, plugin, **kwargs):
time.sleep(1)
print("htlc_accepted called")
return {'result': 'continue'}
plugin.run()