Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script Google应用程序脚本tryLock/waitLock超时限制后续web应用程序调用的累积超时限制?_Google Apps Script_Google Sheets_Timeout_Locking - Fatal编程技术网

Google apps script Google应用程序脚本tryLock/waitLock超时限制后续web应用程序调用的累积超时限制?

Google apps script Google应用程序脚本tryLock/waitLock超时限制后续web应用程序调用的累积超时限制?,google-apps-script,google-sheets,timeout,locking,Google Apps Script,Google Sheets,Timeout,Locking,我一直试图调试一个问题,我正在用GAS将多个新行(通过多个httpget)写入一个google电子表格,但在编写了几行之后,它们似乎无法获得锁。我最初有5000毫秒(5秒)的超时,这对于一个调用来说应该是足够的时间,但我注意到,如果我要添加20行,超时会导致随机行更新失败。 当我把时间移到30秒时,20行就可以了。但如果我去了60行,我又得到了随机失败。移动到60秒超时似乎在那里起作用 似乎这个超时实际上需要考虑写出所有行所需的累计时间。我越想这一点,我就越觉得这是有意义的,因为我是通过一个异步

我一直试图调试一个问题,我正在用GAS将多个新行(通过多个httpget)写入一个google电子表格,但在编写了几行之后,它们似乎无法获得锁。我最初有5000毫秒(5秒)的超时,这对于一个调用来说应该是足够的时间,但我注意到,如果我要添加20行,超时会导致随机行更新失败。 当我把时间移到30秒时,20行就可以了。但如果我去了60行,我又得到了随机失败。移动到60秒超时似乎在那里起作用

似乎这个超时实际上需要考虑写出所有行所需的累计时间。我越想这一点,我就越觉得这是有意义的,因为我是通过一个异步方法从一个flatter/web项目中进行这些调用的。下面HTTP的dart代码获取

  void submitOrder(String orderParms) async {
    try {
      String fullURL = "$URL$orderParms";
      await http.get(fullURL).then((response) {
        callback(convert.jsonDecode(response.body)['status']);
      });
    } catch (e) {
      print(e);
    }
  }
下面的气体道吉特法

function doGet(request){
  var prodID = "1qNt0Q-not-K37U-the-Ea8Fa-real-ynUF-url-xwskYfmDgnMEw2lX_LFblSuDw"; 
  var result = {"status": "SUCCESS"};
  try {
    // Get all Parameters
    var lastName   = request.parameter.lastName;
    var firstName  = request.parameter.firstName;
    var lock = LockService.getUserLock();  
    if (lock.tryLock(60000)) {     // currently using 60 sec to be safe??
      // Open the correct sheetGoogle Sheet using ID
      var sheet_prod = SpreadsheetApp.openById(prodID);
      var rowData    = sheet_prod.appendRow([lastName, firstName]);
      // Need to flush these updates so they fully take before releasing the lock
      SpreadsheetApp.flush();
      // ok, done important spreadsheet stuff, release the lock
      lock.releaseLock();
    // else did not get a lock
    } else {
      result = {"status": "FAILED - No Lock!", "message": "Lock timed out"};      
    }
  } catch(exc){
    result = {"status": "Exception! FAILED", "message": exc.message};
  }
  // Return result
  return ContentService
  .createTextOutput(JSON.stringify(result))
  .setMimeType(ContentService.MimeType.JSON);  
}

我目前将超时设置为60秒,以确保我可以处理30-40行,而不会出现获取锁的故障。将超时设置为这么高有什么害处吗?非常感谢您的任何见解

没有提到使用“大”
毫秒数的任何“危害”,因此这完全取决于是否影响web应用程序的用途和/或电子表格的用途

旁注:由于在您发布文档后,您的代码不会对电子表格进行任何更改,因此没有必要包含
SpreadsheetApp.flush()

文件中没有提到使用“大”的任何“危害”
毫秒数
因此,这完全取决于是否影响web应用程序的用途和/或电子表格的用途


旁注:由于您的代码在发布文档后不会对电子表格进行任何更改,因此不必包含
SpreadsheetApp.flush()

错误消息是什么?你是在哪一行收到的?错误信息是什么?你是在哪一行?