为什么我在 Amazon Kinesis 中收到此代码的 "Rate Exceeded" 错误

Why am I getting "Rate Exceeded" errors for this code in Amazon Kinesis

对于以下代码,我遇到了 "Rate exceeded for shard..." 错误。

from boto import kinesis 
import time

kinesis = kinesis.connect_to_region('us-east-1')
response = kinesis.describe_stream('BenTest')

if response['StreamDescription']['StreamStatus'] == 'ACTIVE':
    print '[x] Stream is active'

    shards = response['StreamDescription']['Shards']
    for shard in shards:
        shard_id = shard['ShardId']
        print "[x] Shard ID: %s"    % shard_id

        shard_it = kinesis.get_shard_iterator('BenTest', shard_id, 'LATEST')['ShardIterator']
        print "[x] Shard iterator: %s" % shard_it
while True:
        out = kinesis.get_records(shard_it, limit=2)
        shard_it = out["NextShardIterator"]
            for o in out['Records']:
                print "[x] %s" % o['Data']
                time.sleep(0.5)

第一次 get_records 调用似乎出错了。

我做错了什么?

取消缩进 time.sleep(0.5) 一级。当没有可用数据时,你疯狂地轮询 api。