【问题标题】:The difference between the request time and the current time is too large请求时间与当前时间相差太大
【发布时间】:2015-01-25 19:05:45
【问题描述】:

我正在从 S3 存储桶下载和删除文件。存储桶有大约 50000 个文件。下载并删除每 10000 个或奇数文件后,我收到此错误。

  File "/Library/Python/2.7/site-packages/boto/s3/key.py", line 544, in delete
    headers=headers)
  File "/Library/Python/2.7/site-packages/boto/s3/bucket.py", line 760, in delete_key
    query_args_l=None)
  File "/Library/Python/2.7/site-packages/boto/s3/bucket.py", line 779, in _delete_key_internal
    response.reason, body)
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>RequestTimeTooSkewed</Code><Message>The difference between the request time and the current time is too large.</Message><RequestTime>Sun, 07 Dec 2014 20:09:54 GMT</RequestTime><ServerTime>2014-12-07T21:09:56Z</ServerTime><MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>

我已经在 Mac 上运行了 NTP,它与 time.apple.com 同步。我还能做些什么来消除这种情况?除了清除之外,有没有更有效的方法来删除 S3 存储桶中的大量文件/密钥?相关代码块:

                try:
                    f.get_contents_to_filename(fname)
                    if (choice=="y"): f.delete()
                except OSError,e:
                    print e

【问题讨论】:

  • 命令运行了多长时间?
  • 运行需要一段时间。一个多小时左右。

标签: amazon-s3 boto


【解决方案1】:

猜猜看,也许boto缓存了时间,而你mac中的振荡器同时不准确。

试试AWS S3提供的“Delete Multiple Objects”API操作,删除很多对象更有效。在 boto 中,它是“boto.s3.bucket.Bucket.delete_keys”。

【讨论】:

  • 您能否详细说明“boto 缓存时间”语句?一个例子?
【解决方案2】:

我们偶尔会看到此错误,尽管执行代码的机器肯定与 NTP 同步并使用 UTC 时区。我们在错误消息中看到的偏移量可能是 30 分钟。

请参阅此处了解如何在 Python 中使用超时装饰器解决此问题的一些观察和建议:

http://www.saltycrane.com/blog/2010/04/using-python-timeout-decorator-uploading-s3/

在 cmets 中,还有另一个建议是使用更短的套接字超时来解决此问题。

我对根本原因的猜测:有时,一个请求会挂在 Amazon 端的队列中,然后会以巨大的延迟进行处理。一些安全检查启动并阻止履行并以错误作为响应。因此,我们这方面可能无法真正“修复”。

【讨论】:

    猜你喜欢
    • 2011-06-13
    • 2018-09-12
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    • 2020-08-19
    相关资源
    最近更新 更多