From efaf634f1b6ef4dd0b37652baf7abfa937b2de4a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 16 Mar 2022 13:36:18 +1030 Subject: [PATCH] commando: make custommsg hook async. Otherwise it blocks everything while it's working, which can be a while for a slow command. Fixes: #347 Signed-off-by: Rusty Russell --- commando/commando.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commando/commando.py b/commando/commando.py index c9a65da..659dfc4 100755 --- a/commando/commando.py +++ b/commando/commando.py @@ -161,8 +161,8 @@ def try_command(plugin, peer_id, idnum, method, params, runestr): send_result(plugin, peer_id, idnum, res) -@plugin.hook('custommsg') -def on_custommsg(peer_id, payload, plugin, **kwargs): +@plugin.async_hook('custommsg') +def on_custommsg(peer_id, payload, plugin, request, **kwargs): pbytes = bytes.fromhex(payload) mtype = int.from_bytes(pbytes[:2], "big") idnum = int.from_bytes(pbytes[2:10], "big") @@ -194,7 +194,7 @@ def on_custommsg(peer_id, payload, plugin, **kwargs): else: # Pass through result finished.req.set_result(ret['result']) - return {'result': 'continue'} + request.set_result({'result': 'continue'}) @plugin.async_method("commando")