From 17d7e681d41f0d305278f48c500431220207bafa Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Mon, 28 Nov 2016 12:47:55 -0700
Subject: [PATCH] Add check for falsey return from socket recv

---
 geomagio/edge/waveserver.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/geomagio/edge/waveserver.py b/geomagio/edge/waveserver.py
index 056d9377c..47ac57c5d 100644
--- a/geomagio/edge/waveserver.py
+++ b/geomagio/edge/waveserver.py
@@ -156,6 +156,8 @@ def get_sock_char_line(sock, timeout=10.):
             # see https://github.com/obspy/obspy/issues/383
             # indat = sock.recv(8192)
             indat = sock.recv(1)
+            if not indat:
+                break
             chunks.append(indat)
     except socket.timeout:
         print('socket timeout in get_sock_char_line()', file=sys.stderr)
@@ -178,6 +180,8 @@ def get_sock_bytes(sock, nbytes, timeout=None):
     try:
         while btoread:
             indat = sock.recv(min(btoread, 8192))
+            if not indat:
+                break
             btoread -= len(indat)
             chunks.append(indat)
     except socket.timeout:
-- 
GitLab