def serveInBackground(port, serverName, prefix='/status/'):
  """Convenience function: spawn a background server thread that will
  serve HTTP requests to get the status. Returns the thread."""
  import flask, threading
  from wsgiref.simple_server import make_server
  app = flask.Flask(__name__)
  registerStatsHandler(app, serverName, prefix)
  server = threading.Thread(target=make_server('', port, app).serve_forever)
  server.daemon = True
  server.start()
  return server