Datastreaming through Websocket


I am looking for help in streaming data through websocket on React application howevers its not happening.

In below code, I have enabled threading but still in emit function its passing data as None and also, terminal getting hang and cant even quite the transaction, need to close terminal.
Ideally below output needs to populate :but its passing None:
Output I am receiving as:

Emitting data_update event with processed data: None
new msg…
{‘MCX:CRUDEOIL23JUN6200CE’: {‘LTP’: 189.9}}
new msg…
{‘MCX:CRUDEOIL23JUN6200CE’: {‘LTP’: 189.9}}

def handle_custom_message(message):
# Process the incoming data from the Fyers API
processed_data = test1.run_process_foreground_symbol_data(message)
# processed_data = “hello”
print(“Emitting data_update event with processed data:”, processed_data)
# Emit the processed data to the connected clients
emit(‘data_update’, processed_data)

from fyers_api.Websocket import ws
import threading, time
live_data = {}

def run_process_foreground_symbol_data(message):
data_type = “symbolData”
ws_access_token = “75J1L-100:”
print(“run_process_foreground_symbol_data”, message, type(message))
symbol =[“MCX:CRUDEOIL23JUN6200CE”]
print(symbol, data_type)
fyersSocket = ws.FyersSocket(access_token=ws_access_token, run_background=False, log_path=“D:\matx-react-master\matx-react-master\backend\otd_backend\logs”)
fyersSocket.websocket_data = custom_message
threading.Thread(target=subscribe_new_symbol, args=(symbol, fyersSocket, data_type)).start()

def subscribe_new_symbol(symbol_list, fyersSocket, data_type):
fyersSocket.subscribe(symbol=symbol_list, data_type=data_type)

def custom_message(msg):
for symbol_data in msg:
live_data[symbol_data[‘symbol’]] = {“LTP”: symbol_data[‘ltp’]}