def background_thread():
 count = 0
 while True:
  socketio.sleep(10)
  count += 1
  socketio.emit('my_response', {'data': 'Server generated event', 'count': count}, namespace='/test')

def background_thread ( ) : count = 0 while True : socketio . sleep ( 10 ) count += 1 socketio . emit ( 'my_response' , { 'data' : 'Server generated event' , 'count' : count } , namespace = '/test' )
handles the timeout logic .