From 15aaf9f49a949a29c50dbb98798724fda5a7d6aa Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Jan 2018 06:59:50 +1030 Subject: [PATCH] test_lightning.py: shutdown tail thread before killing. Seems to avoid the nasty python resource warnings, as well as the fatal 'ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL' Signed-off-by: Rusty Russell --- tests/test_lightningd.py | 6 +++--- tests/utils.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 358c2068d..9cc71dd88 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -2497,7 +2497,7 @@ class LightningDTests(BaseLightningDTests): # Stop l2, l1 will reattempt to connect print("Killing l2 in mid HTLC") - l2.daemon.proc.terminate() + l2.daemon.kill() # Clear the disconnect and timer stop so we can proceed normally l2.daemon.cmd_line = [e for e in l2.daemon.cmd_line if 'disconnect' not in e] @@ -2554,7 +2554,7 @@ class LightningDTests(BaseLightningDTests): l1.daemon.wait_for_log('dev_disconnect: \+WIRE_COMMITMENT_SIGNED') print("Killing l1 in mid HTLC") - l1.daemon.proc.terminate() + l1.daemon.kill() # Restart l1, without disconnect stuff. l1.daemon.cmd_line.remove('--no-reconnect') @@ -2595,7 +2595,7 @@ class LightningDTests(BaseLightningDTests): l1.daemon.wait_for_log('dev_disconnect: \+WIRE_COMMITMENT_SIGNED') print("Killing l1 in mid HTLC") - l1.daemon.proc.terminate() + l1.daemon.kill() # Restart l1, without disconnect stuff. l1.daemon.cmd_line.remove('--no-reconnect') diff --git a/tests/utils.py b/tests/utils.py index 5e34b743e..ff9264716 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -85,6 +85,12 @@ class TailableProc(object): return self.proc.returncode + def kill(self): + """Kill process without giving it warning.""" + self.proc.kill() + self.proc.wait() + self.thread.join() + def tail(self): """Tail the stdout of the process and remember it.