Looking at the code for waitForEmptyQueue
there does seem to be a bug in it, as it doesn’t return False
on a timeout, it throws an exception.
I think it should be:
def waitForEmptyQueue(self, timeout_ms=1000):
"""
Wait until the Pixelblaze's websocket message queue is empty, or until
timeout_ms milliseconds have elapsed. Returns True if an empty queue
acknowldgement was received, False if timeout or error occurs.
"""
self.ws_flush()
self.ws.settimeout(timeout_ms / 1000)
try:
self.send_string('{"ping": true}')
result = self.ws.recv()
self.ws.settimeout(self.default_recv_timeout)
return True if ((result is not None) and (result.startswith('{"ack"'))) else False
except websocket._exceptions.WebSocketTimeoutException:
self.ws.settimeout(self.default_recv_timeout) # restore normal timeout
return False