Regarding Google Apps Script taking a long time to process doPost, doPost is called again

Asked 5 months ago, Updated 5 months ago, 8 views

When Google Apps Script takes time to process doPost, doPost was called again (after 2 minutes), so I tried to prevent it from re-entering with LockService getUserLock and getScriptLock, but I could get the lock. If I POST to compete from other tabs and windows, I can't get the lock. Where's the problem?

function doPost(){

  // var lock = LockService.getUserLock(); 
  var lock = LockService.getScriptLock(); 
  var success=lock.tryLock(3);
  If(!success){// If the lock is not released within 3 seconds, it is determined that the previous processing has not been completed.
    console.error('doPost was called while processing doPost.');
    outHtml=HtmlService.createTemplateFromFile("Wait a minute.");
    return outHtml.evaluate();

    Utilities.sleep (180000);


2022-09-30 14:06

1 Answers

In the end, userProperties recorded the execution state (processed, accepted) as the user's property so that it did not start new processing when called during processing. We also recorded the start time and accepted execution after a certain period of time.

2022-09-30 14:06

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.