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

209
Vistas
Why are all requests sent after an event-stream request stuck in pending?

I have a Flask app that sends an event stream of temperature data to the client. Since the application controls a kiln, it's important that the user can access the job specific controls (Stop, Pause, Resume, etc).

Right now, the chart updates with information coming from the event source, but when I try to change routes to control the kiln itself, the request is stuck in "Pending".

Any advice?

Relevant code:

commands.py

def generate_data(self):
  ...
  while True:
    time.sleep(1)
    temp_data = json.loads(data)
    temp = temp_data['temp']
    json_data = json.dumps({'time': datetime.now(), 'temp': temp})
    yield f"data:{json_data}\n\n"

views.py

...
@app.route('/chart_data')
def chart_data():
  kc = kiln_command.KilnCommand()
  return Response(kc.generate_data(), mimetype='text/event-stream')

show_jobs.html

...
<script>
...
const context = document.getElementById('canvas').getContext('2d')

const lineChart = new Chart(context, config)

const source = new EventSource("/chart_data")

source.onmessage = function (event) {
  const data = JSON.parse(event.data);
  ...
</script>
about 4 years ago · Juan Pablo Isaza
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