I implemented a Web App but it takes around 30 seconds to complete the actions before sending the data to the spreadsheet. In the code I changed huge text for a Utilities.sleep(30000)
to make it easier to see and get the same result:
function doGet(e) {
const lock = LockService.getDocumentLock();
if (lock.tryLock(360000)) {
try {
var backteam = e.parameter.backteam;
var backodds = e.parameter.backodds;
var layteam = e.parameter.layteam;
var layodds = e.parameter.layodds;
var vantagem = e.parameter.advantage;
Utilities.sleep(30000)
var second_sheet = SpreadsheetApp.openById('XXXXXXX');
var second_sheet_page = second_sheet.getSheetByName('STACKTEST');
var r = 1;
while (second_sheet_page.getRange(r, 1).getValue()) {
r++;
}
second_sheet_page.getRange(r, 1, 1, 5).setValues([[backteam,backodds,layteam,layodds,advantage]]);
} catch (e) {
//pass
} finally {
lock.releaseLock();
}
} else {
//pass
}
}
In my Python code:
import requests
backteam = "Vasco"
backodds = "3.00"
layteam = "Flamengo"
layodds = "1.50"
advantage = "25.55"
webAppsUrl = "https://script.google.com/macros/s/XXX/exec"
requests.get(webAppsUrl + "?backteam=" + backteam + "&backodds=" + backodds + "&layteam=" + layteam + "&layodds=" + layodds + "&advantage=" + advantage)
I wouldn't want to wait for the end of execution to continue with the other tasks my Python does (I know I can force a timeout on the request, but then I'm not sure if the Web App received the request).
Is there a way to not have to wait doing something in Google Apps Script?