@@ -460,18 +460,16 @@ async def on_message_for_websocket(
460460 # to get _real_ bytes and then decode it (assuming it to be utf-8)
461461 # in order to get the message as a string! :-O
462462 try :
463- message_string = eval (str (msg )).decode ( # pylint: disable=eval-used
464- "utf-8"
465- )
463+ msg_str = eval (str (msg )).decode ("utf-8" ) # pylint: disable=eval-used
466464 except Exception as ex : # pylint: disable=broad-exception-caught
467465 _LOGGER .error ("Exception trying to decode message %s" , ex )
468466 _LOGGER .info ("TRIMMED %s" , message_context .offset )
469- if message_string [0 ] == "{" :
467+ if msg_str [0 ] == "{" :
470468 _LOGGER .info ("IS JSON %s" , message_context .offset )
471469 # The EventStream Service is permitted to append to the JSON string
472470 # as long as it uses keys with the prefix "ess_"
473471 try :
474- msg_dict : dict [str , Any ] = json .loads (message_string )
472+ msg_dict : dict [str , Any ] = json .loads (msg_str )
475473 except (
476474 json .decoder .JSONDecodeError
477475 ) as jde : # pylint: disable=broad-exception-caught
@@ -481,23 +479,23 @@ async def on_message_for_websocket(
481479 es_id ,
482480 es_websocket_uuid ,
483481 jde ,
484- message_string ,
482+ msg_str ,
485483 )
486484 return
487485 # Now decoded to a dictionary if we get here...
488486 msg_dict ["ess_ordinal" ] = message_context .offset
489487 msg_dict ["ess_timestamp" ] = message_context .timestamp
490- message_string = json .dumps (msg_dict )
488+ msg_str = json .dumps (msg_dict )
491489 else :
492490 # The EventStream Service is permitted to append to the protobuf string
493491 # as long as it uses the '|' delimiter. Here qwe add offset and timestamp.
494- message_string += f"|ordinal: { message_context .offset } "
495- message_string += f"|timestamp: { message_context .timestamp } "
492+ msg_str += f"|ordinal: { message_context .offset } "
493+ msg_str += f"|timestamp: { message_context .timestamp } "
496494
497495 try :
498496 # Pass on and count
499497 _LOGGER .info ("SENDING %s" , message_context .offset )
500- await websocket .send_text (message_string )
498+ await websocket .send_text (msg_str )
501499 _LOGGER .info ("SENT %s" , message_context .offset )
502500 message_stats [_MESSAGE_STATS_KEY_SENT ] = (
503501 message_stats [_MESSAGE_STATS_KEY_SENT ] + 1
0 commit comments