在我的GAE代码中,我将几个文件上传到第三方(不是我的)服务器:
for argument in files_arguments:
files_counter +=1
file_size = len(self.request.get(argument))/(1024.0*1024.0)
if file_size <= 1:
files.append(MultipartParam('file1', self.request.get(argument), 'file'+str(files_counter)+'.jpg', 'application/x-www-form-urlencoded'))
# sending file
data, headers = multipart_encode(files)
# try 3 times to send the file
for i in range(3):
try:
result = urlfetch.fetch(url=self.request.get('upload_url'),
payload=''.join(data),
method=urlfetch.POST,
headers=headers,
deadline=10
)
break
except DownloadError:
logging.error('(POST) ... DownloadError during file upload, attempt ' + str(i))
pass
except DeadlineExceededError:
logging.error('(POST) ... DeadlineExceededError during file upload, attempt ' + str(i))
pass
if result.status_code == 200:
并且在〜第10个文件中我得到了DeadlineExceededError。 我该怎么做才能避免这种情况?
答案 0 :(得分:3)