Skip to content

Commit 8e64048

Browse files
committed
Add comments about why this is coded this way.
1 parent c3f535d commit 8e64048

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

plexapi/alert.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ def stop(self):
5656
self._ws.close()
5757

5858
def _onMessage(self, *args):
59+
""" Called when websocket message is recieved.
60+
In earlier releases, websocket-client returned a tuple of two parameters: a websocket.app.WebSocketApp object
61+
and the message as a STR. Current releases appear to only return the message.
62+
We are assuming the last argument in the tuple is the message.
63+
This is to support compatibility with current and previous releases of websocket-client.
64+
"""
5965
message = args[-1]
60-
""" Called when websocket message is recieved. """
6166
try:
6267
data = json.loads(message)['NotificationContainer']
6368
log.debug('Alert: %s %s %s', *data)
@@ -67,6 +72,11 @@ def _onMessage(self, *args):
6772
log.error('AlertListener Msg Error: %s', err)
6873

6974
def _onError(self, *args): # pragma: no cover
75+
""" Called when websocket error is recieved.
76+
In earlier releases, websocket-client returned a tuple of two parameters: a websocket.app.WebSocketApp object
77+
and the error. Current releases appear to only return the error.
78+
We are assuming the last argument in the tuple is the message.
79+
This is to support compatibility with current and previous releases of websocket-client.
80+
"""
7081
err = args[-1]
71-
""" Called when websocket error is recieved. """
7282
log.error('AlertListener Error: %s' % err)

0 commit comments

Comments
 (0)