Wee-slack: SSLWantReadError unknown

Created on 22 Mar 2018  路  6Comments  路  Source: wee-slack/wee-slack

Regression from https://github.com/wee-slack/wee-slack/pull/495

Host system is running python Python 2.7.6 (I used to get the log spam from _that_ issue, now I get log spam from _this_ issue)

17:07 python: stdout/stderr (slack): Traceback (most recent call last): 17:07 python: stdout/stderr (slack): File "/home/karlp/.weechat/python/autoload/wee_slack.py", line 119, in wrapper 17:07 python: stdout/stderr (slack): return f(*decode_from_utf8(args), **decode_from_utf8(kwargs)) 17:07 python: stdout/stderr (slack): File "/home/karlp/.weechat/python/autoload/wee_slack.py", line 618, in receive_ws_callback 17:07 python: stdout/stderr (slack): EVENTROUTER.receive_ws_callback(args[0]) 17:07 python: stdout/stderr (slack): File "/home/karlp/.weechat/python/autoload/wee_slack.py", line 347, in receive_ws_callback 17:07 python: stdout/stderr (slack): except ssl.SSLWantReadError: 17:07 python: stdout/stderr (slack): AttributeError: 'module' object has no attribute 'SSLWantReadError' 17:07 =!= python: error in function "receive_ws_callback" code

Most helpful comment

@tfheen: That would just get the code to run without catching the exception though, so you would still get the error in the debug log. But since python < 2.7.9 just throws SSLError, maybe that's the best we can do?

All 6 comments

I raised this on IRC, @auscompgeek pointed out SSLWantReadError was introduced in Python 2.7.9.

So is there a fix for this under 2.7.6?

Can you try

diff --git a/wee_slack.py b/wee_slack.py
index 14d56f0..5679728 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -25,6 +25,13 @@ try:
 except:
     from StringIO import StringIO

+# Workaround for older SSL versions not having SSLWantReadError
+try:
+    from ssl import SSLWantReadError
+except ImportError:
+    class SSLWantReadError(Exception):
+        pass
+
 from websocket import create_connection, WebSocketConnectionClosedException

 # hack to make tests possible.. better way?
@@ -344,7 +351,7 @@ class EventRouter(object):
             # TODO: handle reconnect here
             self.teams[team_hash].set_disconnected()
             return w.WEECHAT_RC_OK
-        except ssl.SSLWantReadError:
+        except SSLWantReadError:
             # Expected to happen occasionally on SSL websockets.
             return w.WEECHAT_RC_OK
         except Exception:

and see if that fixes it for you?

Will do. Last night I commented out the except block. :-)

@tfheen: That would just get the code to run without catching the exception though, so you would still get the error in the debug log. But since python < 2.7.9 just throws SSLError, maybe that's the best we can do?

As Python 2 is end of life at the end of this year, I won't support older versions of Python 2, so I'm closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BlitzKraft picture BlitzKraft  路  9Comments

rawdigits picture rawdigits  路  10Comments

tuananh picture tuananh  路  9Comments

neverfox picture neverfox  路  11Comments

simonsmith picture simonsmith  路  5Comments