summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Chapla <shwnchpl@gmail.com>2018-09-01 19:51:01 -0400
committerShawn Chapla <shwnchpl@gmail.com>2018-09-01 19:51:01 -0400
commit16ebf78e9021368da39362f1540d3b86dbb03db4 (patch)
tree76948fb357b68099eeef765f41a05debf88d091a
parentae589495b75162703ab4fe1f8712f50d22b12d4e (diff)
downloadwebsocket-client-16ebf78e9021368da39362f1540d3b86dbb03db4.tar.gz
Fix NoneType bug introduced by #386 fix
-rw-r--r--websocket/_app.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/websocket/_app.py b/websocket/_app.py
index 970f3bd..b83d8a6 100644
--- a/websocket/_app.py
+++ b/websocket/_app.py
@@ -48,7 +48,7 @@ class Dispatcher:
def read(self, sock, read_callback, check_callback):
while self.app.sock.connected:
r, w, e = select.select(
- (self.app.sock.sock, ), (), (), self.ping_timeout) # Use a 10 second timeout to avoid to wait forever on close
+ (self.app.sock.sock, ), (), (), self.ping_timeout)
if r:
if not read_callback():
break
@@ -282,15 +282,15 @@ class WebSocketApp(object):
return True
def check():
- has_timeout_expired = time.time() - self.last_ping_tm > ping_timeout
- has_pong_not_arrived_after_last_ping = self.last_pong_tm - self.last_ping_tm < 0
- has_pong_arrived_too_late = self.last_pong_tm - self.last_ping_tm > ping_timeout
-
- if (ping_timeout
- and self.last_ping_tm
- and has_timeout_expired
- and (has_pong_not_arrived_after_last_ping or has_pong_arrived_too_late)):
- raise WebSocketTimeoutException("ping/pong timed out")
+ if (ping_timeout):
+ has_timeout_expired = time.time() - self.last_ping_tm > ping_timeout
+ has_pong_not_arrived_after_last_ping = self.last_pong_tm - self.last_ping_tm < 0
+ has_pong_arrived_too_late = self.last_pong_tm - self.last_ping_tm > ping_timeout
+
+ if (self.last_ping_tm
+ and has_timeout_expired
+ and (has_pong_not_arrived_after_last_ping or has_pong_arrived_too_late)):
+ raise WebSocketTimeoutException("ping/pong timed out")
return True
dispatcher.read(self.sock.sock, read, check)