Optimize websocket client queue

This commit is contained in:
tomkat83 2016-12-20 16:27:22 +01:00
parent ad8b7c7d90
commit 17fc11d8bb

View file

@ -2,9 +2,8 @@
############################################################################### ###############################################################################
import logging import logging
import json from json import loads
import threading import threading
import Queue
import websocket import websocket
import ssl import ssl
@ -36,7 +35,7 @@ class WebSocket(threading.Thread):
return False return False
try: try:
message = json.loads(message) message = loads(message)
except Exception as ex: except Exception as ex:
log.error('Error decoding message from websocket: %s' % ex) log.error('Error decoding message from websocket: %s' % ex)
log.error(message) log.error(message)
@ -57,13 +56,8 @@ class WebSocket(threading.Thread):
return True return True
# Put PMS message on queue and let libsync take care of it # Put PMS message on queue and let libsync take care of it
try: self.queue.put(message)
self.queue.put(message) return True
return True
except Queue.Full:
# Queue only takes 200 messages. No worries if we miss one or two
log.info('Queue is full, dropping PMS message %s' % message)
return False
def receive(self, ws): def receive(self, ws):
# Not connected yet # Not connected yet