我最近开始收到此异常:
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()
,它都会产生这个错误。如有必要,我可以提供项目密钥。