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

332
Vistas
Python: How to use POST or GET methods in infinite loop?

I have a simple json REST server on my LAN. I need to let clients on the LAN POST/PUT and GET camera live stream seamlessly over http. I tried two simple approaches:

Method1 (without Session):

while (frame):
   dict_obj = image_to_dict_converter(frame)
   json_obj = str(json.loads(dict_obj))
   requests.put(url, headers=headers, data = json.dumps({'data': str(json.loads(json_obj))}), timeout = 0.1)

Method2 (with Session):

ses = requests.Session()
while (frame):
   dict_obj = image_to_dict_converter(frame)
   json_obj = str(json.loads(dict_obj))
   ses.put(url, headers=headers, data = json.dumps({'data': str(json.loads(json_obj))}),timeout = 0.1)

Same methods are used withGET. I tried both on Apache2 and Nginx, and since Nginx resulted in better performance, my REST server is now linked to Nginx. I am able to stream and visualize the video on a client-server-client topology. Method2 works smoothly (~0 sec latency) and at high fps, it however freezes once a while for 6 seconds (probably Session is limited to a number of calls). Method1 works reliably, however, at low fps and with 0.5 sec constant latency in frames.

My question is how can I technically improve the methods for realtime services? (Can anyone provide an example?) Also, how can I tune Nginx to handle such service in terms of speed and number of requests?

UPDATE:
I noticed that web server (Nginx) is interrupting the stream, it has no issues when requests are redirected directly to the port number my REST listens to (localhost:8888) instead of localhost (managed by Nginx)

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