Skip to content

Commit 3e7b3ab

Browse files
committed
output more user-friendly log in message serialization error
1 parent 34f4c19 commit 3e7b3ab

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pywebio/platform/tornado.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ def send_msg_to_client(cls, _, session_id=None):
144144
return
145145

146146
for msg in session.get_task_commands():
147-
conn.write_message(json.dumps(msg))
147+
try:
148+
conn.write_message(json.dumps(msg))
149+
except TypeError as e:
150+
logger.exception('Data serialization error: %s\n'
151+
'This may be because you pass the wrong type of parameter to the function'
152+
' of PyWebIO.\nData content: %s', e, msg)
148153

149154
@classmethod
150155
def close_from_session(cls, session_id=None):

0 commit comments

Comments
 (0)