2012-11-27 10 views
8

मैं अजगर उपयोग कर रहा हूँ और Botoअमेज़न निर्दिष्ट कुंजी S3 get_key सफलता के बाद अस्तित्व में नहीं है

इस

मेरी कोड है:

key = bucket.get_key(key_name) 
if not key: 
    print 'error, key does not exist' 
    return 
data = key.get_contents_as_string() 

कभी कभी (बेतरतीब ढंग से दिखाई देता है) मैं इस अपवाद:

S3ResponseError: S3ResponseError: 404 Not Found

नोट: फ़ाइल एक सर्वर द्वारा अपलोड की जाती है और उसके तुरंत बाद एक और सर्वर (एक अलग महाद्वीप में स्थित) ऊपर कोड चला रहा है।

ट्रैस बैक:

Traceback (most recent call last): File "/test.py", line 222, in _process_response

data = key.get_contents_as_string() File "/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg/boto/s3/key.py",

line 1201, in get_contents_as_string response_headers=response_headers) File "/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg/boto/s3/key.py",

line 1093, in get_contents_to_file response_headers=response_headers) File "/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg/boto/s3/key.py",

line 996, in get_file override_num_retries=override_num_retries) File "/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg/boto/s3/key.py",

line 211, in open override_num_retries=override_num_retries) File "/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg/boto/s3/key.py",

line 165, in open_read self.resp.reason, body) S3ResponseError: S3ResponseError: 404 Not Found

NoSuchKey The specified key does not exist.key_nameidhost_id

तो मैं चाबी ले, लेकिन फिर मैं जब मैं कोशिश करते हैं और इसे से पढ़ होते हैं यह 'नहीं मिला'। कोई विचार?

उत्तर

8

यह व्यवहार की उम्मीद है, Amazon S3 developer guide के अनुसार:

... However, information about the changes might not immediately replicate across Amazon S3 and you might observe the following behaviors: A process writes a new object to Amazon S3 and immediately attempts to read it. Until the change is fully propagated, Amazon S3 might report "key does not exist."

संबंधित मुद्दे