Optimize websocket client queue
This commit is contained in:
parent
ad8b7c7d90
commit
17fc11d8bb
1 changed files with 4 additions and 10 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue