Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

334
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda