Skip to content

Commit e6ec0f4

Browse files
Avoid spurious error logs at service termination
When we terminate a service, all the remote service clients are disconnected, closing their sockets. The ongoing, never-ending read then terminates with an error (socket closed in another greenlet), but in this case it is expected.
1 parent e5927d2 commit e6ec0f4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

cms/io/rpc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,14 @@ def _read(self):
248248
self.finalize("Client misbehaving.")
249249
raise IOError("Message too long.")
250250
except socket.error as error:
251-
logger.warning("Failed reading from socket: %s.", error)
252-
self.finalize("Read failed.")
253-
raise error
251+
if self.connected:
252+
logger.warning("Failed reading from socket: %s.", error)
253+
self.finalize("Read failed.")
254+
raise error
255+
else:
256+
# The client was terminated willingly; its correct termination
257+
# is handled in disconnect(), so here we can just return.
258+
return b""
254259

255260
return data
256261

0 commit comments

Comments
 (0)