parameters: ()
docstring: Check regularly the simulation servers load and notify the client if availability changed.
docstring_summary: Check regularly the simulation servers load and notify the client if availability changed.
docstring_tokens: Check regularly the simulation servers load and notify the client if availability changed .
function: def update_load():
      """Check regularly the simulation servers load and notify the client if availability changed."""
      """This function should take no more than 1 second because the timeout is set to this value and requests are threaded."""
      global LOAD_REFRESH
      global availability
      global simulation_server_loads
      threads = [threading.Thread(target=retrieve_load, args=(config['simulationServers'][i], i))
                 for i in range(len(config['simulationServers']))]
      for t in threads:
          t.start()
      for t in threads:
          t.join()
      new_availability = False
      for i in range(len(config['simulationServers'])):
          if simulation_server_loads[i] < LOAD_THRESHOLD:
              new_availability = True
      if new_availability != availability:
          availability = new_availability
          if availability:
              message = '1'
          else:
              message = '0'
          for client in ClientWebSocketHandler.clients:
              client.write_message(message)
  
      tornado.ioloop.IOLoop.current().add_timeout(int(time.time()) + LOAD_REFRESH, update_load)
function_tokens: def update_load ( ) : """This function should take no more than 1 second because the timeout is set to this value and requests are threaded.""" global LOAD_REFRESH global availability global simulation_server_loads threads = [ threading . Thread ( target = retrieve_load , args = ( config [ 'simulationServers' ] [ i ] , i ) ) for i in range ( len ( config [ 'simulationServers' ] ) ) ] for t in threads : t . start ( ) for t in threads : t . join ( ) new_availability = False for i in range ( len ( config [ 'simulationServers' ] ) ) : if simulation_server_loads [ i ] < LOAD_THRESHOLD : new_availability = True if new_availability != availability : availability = new_availability if availability : message = '1' else : message = '0' for client in ClientWebSocketHandler . clients : client . write_message ( message ) tornado . ioloop . IOLoop . current ( ) . add_timeout ( int ( time . time ( ) ) + LOAD_REFRESH , update_load )