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

244
Visualizações
PHP Long Runing Process - respond back to caller, but continue with processing

Hi All,

I have implemented a REST API in PHP to return data to another application upon request. Some requests can take 30 seconds, some take 2 minutes and others can take up to an hour. If the response takes longer than 2 minutes, l need to respond back to the calling application that l will be making a callback to the calling application, once the data extract completes.

The data request can be small or very large - dependent upon what the calling application requires.

I have Google'ed around and come across the pThreads implementation, but it says that it should NOT be used in an application hosted on a WebServer. Amp looks like what l need, but l need the http response to terminate with the calling application, while the SQL continues to be generated - i.e. the http request to continue.

The other solution, that l want to avoid is to mark certain requests as long running - since some requests can take 30 seconds at certain times of the day, but exceed 2 mins at other points of the day.

The requirements are as follows:

  • Accept the request - and run the SQL to extract the data
  • If the SQL request is still running after 2 minutes, then respond back with a JSON response saying that l will use the call back mechanism. But the SQL request needs to continue, and the JSON data to be written to a flat file for the callback
  • If the SQL request completes in less than 2 minutes, respond back with the JSON response with the data

The issue is that once the SQL Request is running, the program blocks until it completes. I need the SQL request to run in a separately, and monitor how long it is taking.

Can anybody provide some sample code, and framework/ library that can help with the above?

I would gratefully accept any help with the above.

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