Skip to content

Commit 42bfde0

Browse files
committed
Merge pull request slackapi#28 from zoni/detect_disconnects
Detect disconnected websocket connections
2 parents 39de600 + 6687b1a commit 42bfde0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

slackclient/_server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from slackclient._channel import Channel
33
from slackclient._user import User
44
from slackclient._util import SearchList
5+
from ssl import SSLWantReadError
56

67
from websocket import create_connection
78
import json
@@ -106,8 +107,9 @@ def websocket_safe_read(self):
106107
while True:
107108
try:
108109
data += "{}\n".format(self.websocket.recv())
109-
except:
110-
return data.rstrip()
110+
except SSLWantReadError:
111+
return ''
112+
return data.rstrip()
111113

112114
def attach_user(self, name, id, real_name, tz):
113115
self.users.append(User(self, name, id, real_name, tz))

0 commit comments

Comments
 (0)