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>
19 lines
338 B
Python
Executable File
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()
|