2019-01-22 23:23:34 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""This plugin is used to check that async method calls are working correctly.
|
|
|
|
|
|
|
|
The plugin registers a method `callme` with an argument. All calls are
|
|
|
|
stashed away, and are only resolved on the fifth invocation. All calls
|
|
|
|
will then return the argument of the fifth call.
|
|
|
|
|
|
|
|
"""
|
|
|
|
from lightning import Plugin
|
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.init()
|
|
|
|
def init(configuration, options, plugin):
|
|
|
|
plugin.requests = []
|
|
|
|
|
|
|
|
|
2019-02-21 15:22:07 +01:00
|
|
|
@plugin.async_method('asyncqueue')
|
2019-01-22 23:23:34 +01:00
|
|
|
def async_queue(request, plugin):
|
|
|
|
plugin.requests.append(request)
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.method('asyncflush')
|
|
|
|
def async_flush(res, plugin):
|
|
|
|
for r in plugin.requests:
|
|
|
|
r.set_result(res)
|
|
|
|
|
|
|
|
|
|
|
|
plugin.run()
|