From 383b309a00328574df6c79e02b81e8ad09b368ad Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 4 Jun 2018 13:58:52 +0930 Subject: [PATCH] utils: make subd_pid return the *last* pid, in case we restarted daemon. Signed-off-by: Rusty Russell --- tests/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 850667f3c..3bafa0df3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -472,8 +472,13 @@ class LightningNode(object): def subd_pid(self, subd): """Get the process id of the given subdaemon, eg channeld or gossipd""" - pidline = self.daemon.is_in_log('lightning_{}.*: pid [0-9]*,'.format(subd)) - return re.search(r'pid ([0-9]*),', pidline).group(1) + ex = re.compile(r'lightning_{}.*: pid ([0-9]*),'.format(subd)) + # Make sure we get latest one if it's restarted! + for l in reversed(self.daemon.logs): + group = ex.search(l) + if group: + return group.group(1) + raise ValueError("No daemon {} found".format(subd)) def is_channel_active(self, chanid): channels = self.rpc.listchannels()['channels']