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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/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 服务在短时间内调用的次数太多:exec qps。(谷歌脚本)_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 服务在短时间内调用的次数太多:exec qps。(谷歌脚本)

Google apps script 服务在短时间内调用的次数太多:exec qps。(谷歌脚本),google-apps-script,google-sheets,Google Apps Script,Google Sheets,最近,我的一些应用程序脚本在同时执行时显示错误。多年来,一切都运转良好,很明显,谷歌方面发生了变化 这是执行记录结果: 不幸的是,错误没有显示文件名和行号以正确调试,但我的第一行是: var ss = SpreadsheetApp.getActiveSpreadsheet() 因此,我假设应用程序实例同时调用SpreadsheetApp会导致错误。SpreadsheetApp不在循环中,也不在任何函数中。调用它是为了定义应用程序要使用的全局变量ss 我的应用程序以我的用户名执行,因为用户不应

最近,我的一些应用程序脚本在同时执行时显示错误。多年来,一切都运转良好,很明显,谷歌方面发生了变化

这是执行记录结果:

不幸的是,错误没有显示文件名和行号以正确调试,但我的第一行是:

var ss = SpreadsheetApp.getActiveSpreadsheet()
因此,我假设应用程序实例同时调用SpreadsheetApp会导致错误。SpreadsheetApp不在循环中,也不在任何函数中。调用它是为了定义应用程序要使用的全局变量ss

我的应用程序以我的用户名执行,因为用户不应该访问我正在访问的电子表格。恐怕我无法将整个电子表格保存在缓存服务中-我希望应用程序在调用电子表格时更新电子表格

更新:

下面是其中一个应用程序中的一些相关代码

function doGet(e){

  var ref = e.parameter.ref;
  var ss = SpreadsheetApp.openById('########')
  var logsheet = ss.getSheetByName('LOG');
  logsheet.appendRow([new Date(),ref,JSON.stringify(e.parameter)])
  try{
     //Main code goes here
     return ContentService.createTextOutput(JSON.stringify({result:"ok"})).setMimeType(ContentService.MimeType.JSON);
  }catch(e){
     return ContentService.createTextOutput(JSON.stringify(e)).setMimeType(ContentService.MimeType.JSON)}
}

正如您所看到的,我在函数中使用了try{}catch(e),由于我得到的错误没有被它捕获,我假设它就发生在前面。

您可以将所有内容都放在try-catch块中。还记得在执行之前发布新版本的web应用程序

function doGet(e) {
    var response = {};
    try {
        SpreadsheetApp.openById('########')
            .getSheetByName('LOG')
            .appendRow([new Date(), e.parameter.ref, JSON.stringify(e.parameter)]);
        response.result = "OK";
    } catch (error) {
        response.result = "Error: " + error.toString();
    }

    return ContentService
        .createTextOutput(JSON.stringify(response))
        .setMimeType(ContentService.MimeType.JSON);
}

刚刚发现手动破解以避免此错误:


从专用浏览器模式打开电子表格。这将增加文档查看器的数量并增加限制:)

您能否从脚本中共享更多的代码行。您好,阿米特,我从您的示例中学到了很多,谢谢!我添加了一个示例代码。错误甚至在主执行开始之前发生,这表明需要处理SpreadsheetApp调用。有时我的应用程序每分钟被调用20-30次。没什么大不了的,应该妥善处理,imo。至少它在几年内运行良好。谢谢你,实际上这是我尝试的第一件事,但它不起作用。正如您所看到的,如果在函数中捕获到错误,那么它应该返回JSON,并将错误详细信息作为字符串,但我看到的是带有错误消息的google脚本网页。因此,错误的发生超出了范围。我将尝试抓取屏幕截图。看起来不仅仅是SpreadsheetApp,还有几个urlFetch调用也触发了此错误。配额限制在并发应用程序执行量没有明确配额时可用。此外,我得到的错误是“exec qps”-与任何已知服务都不对应。我注意到,在晚上,当我的用户不在办公室时,我没有收到这个错误。我想我可能已经开始达到可以同时使用我的应用程序的最大用户数了。我有十几个应用程序,他们使用了一些电子表格作为数据库,几个月前我尝试对其进行优化,并实施了缓存服务,但显然,当我开始执行一些批处理任务时,它接近极限。也许,我应该考虑移动应用程序引擎…