2012-10-05 25 views
0

我的代码的Python:TLS/SSL连接已关闭

conn = __get_s3_connection(s3_values.get('accessKeyId'), s3_values.get('secretAccessKey')) 
key = s3_values.get('proposal_key') + proposal_unique_id + s3_values.get('proposal_append_path') 
request = urllib2.Request(conn.generate_url(s3_values.get('expires_in'), 'GET', bucket=s3_values.get('bucket'), key=key)) 
request.add_header('Accept-encoding', 'gzip') 
response = urllib2.urlopen(request) 

的URL看起来像https://production.myorg.s3.amazonaws.com/key/document.xml.gz?Signature=signature%3D&Expires=1349462207&AWSAccessKeyId=accessId

这种方法工作正常,直到1小时回来,但是当我运行同一程序,它抛出

Traceback (most recent call last): 
    File "/Users/hhimanshu/IdeaProjects/analytics/src/utilities/documentReader.py", line 145, in <module> 
    main() 
    File "/Users/hhimanshu/IdeaProjects/analytics/src/utilities/documentReader.py", line 141, in main 
    x = get_proposal_data_from_s3('documentId') 
    File "/Users/hhimanshu/IdeaProjects/analytics/src/utilities/documentReader.py", line 54, in get_proposal_data_from_s3 
    response = urllib2.urlopen(request) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen 
    return _opener.open(url, data, timeout) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 392, in open 
    response = self._open(req, data) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 410, in _open 
    '_open', req) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 370, in _call_chain 
    result = func(*args) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1194, in https_open 
    return self.do_open(httplib.HTTPSConnection, req) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1161, in do_open 
    raise URLError(err) 
urllib2.URLError: <urlopen error [Errno 6] _ssl.c:503: TLS/SSL connection has been closed> 

可能是什么原因?我怎样才能避免这种情况?

回答

2

这是因为间歇性的互联网连接。解决它自己

+0

你可以接受你自己的答案,顺便说一句 – 9000

+0

我试过了,所以说你必须等待24小时,我会明天去做 – daydreamer

相关问题