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

171
Visualizações
How to ignore Execution time of Google script and JS

I have for loop here for calling API calls from ticketmaster website and import in google sheets. The problem is I can't make many API calls at once I have to wait about 1 second.

So when I make the loop wait 1 second for example if the array has 40 element I wait 40 sec. No problem with that due to the massive data but when the fucntion wait it gives an error of execution time limit, I need to set the execution time unlimited.

for (var Veunue_id1 = 0; Veunue_id1 < Venue_Id_List.length; Veunue_id1++) {


  var Venue_API_Url = "https://app.ticketmaster.com/discovery/v2/venues?apikey=" + API_key + "&keyword=" + Venue_Id_List[Veunue_id1] + "&locale=*";


  // ImportJSON(url, "/","noInherit,noTruncate,rawHeaders");
  // console.log(ImportJSON(url, "/", "noInherit,noTruncate,rawHeaders"));

  //  console.log("Veuneid" + Veunue_id + Venue_Id_List.length);
  

  results = results.concat(ImportJSON(Venue_API_Url, "/_embedded/venues/id", "noInherit,noTruncate,rawHeaders"));
  console.log(results);

// wait1 second
 Utilities.sleep(1000);



}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This a common issue, especially when working with heavy data API. General approach is:

  1. Run as much as you can, until timeout(6 min) is close
  2. Save loaded data
  3. Store some indicator on there to resume on next run
  4. On next run, repeat from position saved in 3)
  5. Put this on trigger.

Example code based on your situation (not tested)

function SimpleTimer(timeout){
  var start = Date.now();
  this.getElapsed = () => Date.now() - start;
  this.isTimeout = () => this.getElapsed() > timeout;  
}

function resetProgress(){
  PropertiesService.getScriptProperties().setProperty('last', '-1')
}

function test_SimpleTimer() {
  var timer = new SimpleTimer(4*60*1000) // 4 min;

  var start = PropertiesService.getScriptProperties().getProperty('last') || '-1';

  for (var Veunue_id1 = parseInt(start) + 1; Veunue_id1 < Venue_Id_List.length && ! timer.isTimeout(); Veunue_id1++) {
    var Venue_API_Url = "https://app.ticketmaster.com/discovery/v2/venues?apikey=" + API_key + "&keyword=" + Venue_Id_List[Veunue_id1] + "&locale=*";       

    results = results.concat(ImportJSON(Venue_API_Url, "/_embedded/venues/id", "noInherit,noTruncate,rawHeaders"));

    Utilities.sleep(1000);
    PropertiesService.getScriptProperties().setProperty('last', '' + Veunue_id1)
  }
    // SAVE YOUR DATA HERE, NEXT CALL WILL PROCEED FROM LAST STEP

}
about 4 years ago · Juan Pablo Isaza Relatório
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