Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

257
Vistas
Uvicorn Detect --reload Main Thread

I have a simple Uvicorn application (built with FastAPI). In development, uvicorn server:app --reload. The --reload paramter means two threads will be started, one with the server, one to monitor file changes—when a file change is detected, the thread with the server is restarted.

Nothing special thus far. This is common in Flask, Django, and other dev servers as well. The catch is, I want to open a tunnel using pyngrok when I start the dev server, and I want that tunnel to be as long lived as the parent of these two threads. That is to say, when a file change is detected and the dev server is restarted, I do not want the tunnel to be restarted (since with ngrok this would cause a new public URL to be generated and break existing connections).

With Flask and Django this is relatively easy to accomplish. For example, with Flask I simply do os.environ.get("WERKZEUG_RUN_MAIN") != "true", with Django I similarly evaluate the RUN_MAIN environment variable, and in either case I only instantiate the tunnel when this these are set to true. I can't find a similar variable to use with Uvicorn. Can anyone help out here?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda