在Referred中重试未处理的错误:在scrapy中

时间:2016-11-16 23:07:44

标签: python amazon-web-services amazon-s3 scrapy boto

在将图像上传到AWS S3时,我在Scrapy中得到BotoServerError,因为它恰好是服务器关闭。如何处理这些错误,以便我可以将项目管道设置为休眠一段时间并再次重试上载?

2016-11-17 05:59:55 [twisted] CRITICAL: 
Traceback (most recent call last):
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\twisted\python\threadpool.py", line 246, in inContext
    result = inContext.theWork()
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\twisted\python\threadpool.py", line 262, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\twisted\python\context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\twisted\python\context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\s3\key.py", line 1426, in set_contents_from_string
    encrypt_key=encrypt_key)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\s3\key.py", line 1293, in set_contents_from_file
    chunked_transfer=chunked_transfer, size=size)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\s3\key.py", line 750, in send_file
    chunked_transfer=chunked_transfer, size=size)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\s3\key.py", line 951, in _send_file_internal
    query_args=query_args
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\s3\connection.py", line 668, in make_request
    retry_handler=retry_handler
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\connection.py", line 1071, in make_request
    retry_handler=retry_handler)
  File "D:\Kerja\HIT\PYTHON~1\<project_name>\<project_name>\lib\site-packages\boto\connection.py", line 1028, in _mexe
    raise BotoServerError(response.status, response.reason, body)
BotoServerError: BotoServerError: 503 Service Unavailable

1 个答案:

答案 0 :(得分:0)

感谢@paul!根据他的回答,我通过卸载包boto并安装包boto3来解决它。