media/tools/constrained_network_server/cns.py
def Main():
  """Configure and start the ConstrainedNetworkServer."""
  options = ParseArgs()

  try:
    traffic_control.CheckRequirements()
  except traffic_control.TrafficControlError as e:
    cherrypy.log(e.msg)
    return

  cherrypy.config.update({'server.socket_host': '::',
                          'server.socket_port': options.port})

  if options.threads:
    cherrypy.config.update({'server.thread_pool': options.threads})

  if options.socket_timeout:
    cherrypy.config.update({'server.socket_timeout': options.socket_timeout})

  # Setup port allocator here so we can call cleanup on failures/exit.
  pa = PortAllocator(options.port_range, expiry_time_secs=options.expiry_time)

  try:
    cherrypy.quickstart(ConstrainedNetworkServer(options, pa))
  finally:
    # Disable Ctrl-C handler to prevent interruption of cleanup.
    signal.signal(signal.SIGINT, lambda signal, frame: None)
    pa.Cleanup(all_ports=True)
Configure and start the ConstrainedNetworkServer.
Configure and start the ConstrainedNetworkServer.
Configure and start the ConstrainedNetworkServer .
def Main():
  options = ParseArgs()
  try:
    traffic_control.CheckRequirements()
  except traffic_control.TrafficControlError as e:
    cherrypy.log(e.msg)
    return
  cherrypy.config.update({'server.socket_host': '::',
                          'server.socket_port': options.port})
  if options.threads:
    cherrypy.config.update({'server.thread_pool': options.threads})
  if options.socket_timeout:
    cherrypy.config.update({'server.socket_timeout': options.socket_timeout})
  pa = PortAllocator(options.port_range, expiry_time_secs=options.expiry_time)
  try:
    cherrypy.quickstart(ConstrainedNetworkServer(options, pa))
  finally:
    signal.signal(signal.SIGINT, lambda signal, frame: None)
    pa.Cleanup(all_ports=True)
def Main ( ) : options = ParseArgs ( ) try : traffic_control . CheckRequirements ( ) except traffic_control . TrafficControlError as e : cherrypy . log ( e . msg ) return cherrypy . config . update ( { 'server.socket_host' : '::' , 'server.socket_port' : options . port } ) if options . threads : cherrypy . config . update ( { 'server.thread_pool' : options . threads } ) if options . socket_timeout : cherrypy . config . update ( { 'server.socket_timeout' : options . socket_timeout } ) pa = PortAllocator ( options . port_range , expiry_time_secs = options . expiry_time ) try : cherrypy . quickstart ( ConstrainedNetworkServer ( options , pa ) ) finally : signal . signal ( signal . SIGINT , lambda signal , frame : None ) pa . Cleanup ( all_ports = True )
Configure and start the ConstrainedNetworkServer.
Configure and start the ConstrainedNetworkServer .
"""Configure and start the ConstrainedNetworkServer.""" # Setup port allocator here so we can call cleanup on failures/exit. # Disable Ctrl-C handler to prevent interruption of cleanup.