mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
validate:launcher: Be a bit more resilient in GstValidateListener
And handle exception decoding received json info
This commit is contained in:
parent
cd19b10d45
commit
d73e283691
1 changed files with 16 additions and 3 deletions
|
@ -651,21 +651,34 @@ class GstValidateTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class GstValidateListener(socketserver.BaseRequestHandler):
|
class GstValidateListener(socketserver.BaseRequestHandler, Loggable):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
Loggable.__init__(self, "GstValidateListener")
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
"""Implements BaseRequestHandler handle method"""
|
"""Implements BaseRequestHandler handle method"""
|
||||||
test = None
|
test = None
|
||||||
|
self.logCategory = "GstValidateListener"
|
||||||
while True:
|
while True:
|
||||||
raw_len = self.request.recv(4)
|
raw_len = self.request.recv(4)
|
||||||
if raw_len == b'':
|
if raw_len == b'':
|
||||||
return
|
return
|
||||||
msglen = struct.unpack('>I', raw_len)[0]
|
msglen = struct.unpack('>I', raw_len)[0]
|
||||||
msg = self.request.recv(msglen).decode()
|
try:
|
||||||
|
msg = self.request.recv(msglen).decode('utf-8', 'ignore')
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
self.error("Could not decode message: %s - %s" % (msg, e))
|
||||||
|
continue
|
||||||
if msg == '':
|
if msg == '':
|
||||||
return
|
return
|
||||||
|
|
||||||
obj = json.loads(msg)
|
try:
|
||||||
|
obj = json.loads(msg)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
self.error("Could not deserialize: %s - %s" % (msg, e))
|
||||||
|
continue
|
||||||
|
|
||||||
if test is None:
|
if test is None:
|
||||||
# First message must contain the uuid
|
# First message must contain the uuid
|
||||||
|
|
Loading…
Reference in a new issue