2

我最近开始收到此异常:

driveWriteVolume rateMax. Try Utilities.sleep(1000) between calls

通常这意味着我正在尝试快速重复访问服务。但是,我以前从未见过此消息,并且我进行的任何搜索都不会返回任何有用的信息。

这是我可以在不粘贴 100 行代码的情况下做的最好的模型:

function compileLabel(){
   var doc = DocsList.createFile('My Label', '', 'text/html');
   var threads = GmailApp.getUserLabelByName('My Label');

   var startTime = Date.now();
   while((Date.now() - startTime) < 240000){

     for(t in threads){
        var messages = threads[t].getMessages();
        var threadHeader = createThreadHeader(); //Builds HTML representation of thread info as string
        doc.append(threadHeader);

        for(m in messages){
           var msgHeader = createMessageHeader(); //Builds HTML representation from header info as string
           doc.append(msgHeader);
           doc.append(messages[i].getBody());

           var attachments = messages[m].getAttachments();
           if(attachments.length > 0){
              var attachmentFolder = parentFolder.createFolder(messages[m].getSubject());
           }
           for(a in attachments){
             attachmentFolder.createFile(attachments[a]);
           }
        }
     }
   }

   parentFolder.createFile(doc.getAs('application/pdf')); //this is intermittantly throwing an exception about serialization now, but that's probably a different issue.
   //After time based loop, do more things that don't have any DocsList based functions
}

截至2天前,这工作得很好。现在,除非 Isleep(1000)在每个doc.append(), createFile()or之前createFolder(),它都会产生这个错误。如有必要,我可以提供项目密钥。

4

1 回答 1

0

我今天发现了同样的错误邮件,显然我超过了 Google Drive 允许的上传速度。为了解决这个问题,我不得不将睡眠时间增加到 3000(我已经使用了 1000)。这是导致错误的一段代码:

  var att = messages[y].getAttachments(); 
  var attlinks = [];  
  for (var z=0; z<att.length; z++) {
    try {
      var file = folder.createFile(att[z]); //create file in gdrive
      attlinks.push('<a href="'+file.getUrl()+'" target="_blank" alt="'+file.getName()+'">'+file.getName()+'</a>'); //push link to array
      Utilities.sleep(3000); //increased from 1000 to 3000
    }

更新

我不得不再次增加睡眠时间(到 10 秒),因为当附件超过 5 个时问题仍然存在。

于 2013-05-10T13:39:24.793 回答