5
종종 GAE는 파일을 업로드 할 수 없습니다 나는 다음과 같은 오류가 점점 오전 :오류가 발생하면 urlfetch.fetch를 몇 번 더 다시 시도 하시겠습니까?
ApplicationError: 2
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 636, in __call__
handler.post(*groups)
File "/base/data/home/apps/picasa2vkontakte/1.348093606241250361/picasa2vkontakte.py", line 109, in post
headers=headers
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 260, in fetch
return rpc.get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
return self.__get_result_hook(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 355, in _get_fetch_result
raise DownloadError(str(err))
DownloadError: ApplicationError: 2
어떻게 같은 오류가 발생하는 경우에 재 시도를 수행해야합니까?
try:
result = urlfetch.fetch(url=self.request.get('upload_url'),
payload=''.join(data),
method=urlfetch.POST,
headers=headers
)
except DownloadError:
# how to retry 2 more times?
# and how to verify result here?
감사합니다. @Drew Sears. 'status_code'를 확인하는 것이 맞을까요? if result.status_code == 200 : break'? –
필요하지 않아야합니다. fetch가 실패 코드 (404, 500)를 반환하면 예외가 throw되고 break를 포함하여 try 블록의 아무 것도 실행되지 않습니다. –