From 01f34faef6c0ad4d28bb5aaa624d9966ad3a260d Mon Sep 17 00:00:00 2001 From: Francesco Burelli Date: Sun, 19 Feb 2023 14:31:43 +0100 Subject: [PATCH] Fix pigpio socket loop when connection closes --- pigpio.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pigpio.py b/pigpio.py index 20d48e6..665b44a 100644 --- a/pigpio.py +++ b/pigpio.py @@ -1194,8 +1194,10 @@ class _callback_thread(threading.Thread): while self.go: buf += self.sl.s.recv(RECV_SIZ) - offset = 0 + if len(buf) == 0: + self.stop() + offset = 0 while self.go and (len(buf) - offset) >= MSG_SIZ: msgbuf = buf[offset:offset + MSG_SIZ] offset += MSG_SIZ