Skip to contentSkip to conversation

asyncrpc: serv: correct closed client socket detection

PATCH New Justin Bronder 1 participant 1 message Oct 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asyncrpc: serv: correct closed client socket detection

If the client socket is closed, asyncio.StreamReader.readline() will return an empty bytes object, not None.

This prevents multiple tracebacks being logged by bitbake-hashserv each time bitbake is started and performs a connection check.

---
 lib/bb/asyncrpc/serv.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/asyncrpc/serv.py +2 -2
index 5cf45f908..d2de4891b 100644
@@ -42,7 +42,7 @@ class AsyncServerConnection(object):
 
             # Read protocol and version
             client_protocol = await self.reader.readline()
-            if client_protocol is None:
+            if not client_protocol:
                 return
 
             (client_proto_name, client_proto_version) = client_protocol.decode('utf-8').rstrip().split()
@@ -59,7 +59,7 @@ class AsyncServerConnection(object):
             # an empty line to signal the end of the headers
             while True:
                 line = await self.reader.readline()
-                if line is None:
+                if not line:
                     return
 
                 line = line.decode('utf-8').rstrip()
Signature · 1 line
2.38.0