我在发送请求时使用Jython 2.7有时会发生错误(在SSL握手期间遇到此失败java.lang.NullPointerException)

时间:2015-10-23 10:45:08

标签: python jython jython-2.5 jython-2.7

我的代码:

@trust_all_certificates
def go_url(self, url, data=None, headers={}):
    global response
    request = urllib2.Request(url, data, headers)
    request.add_header('Authorization', 'Basic %s' % self.AdminAuthBase64)
    for x in xrange(3):
        try:
            response = urllib2.urlopen(request)
            break
        except IOError, e:
            if hasattr(e, 'reason'):
                API.log('We failed to reach a server. Reason: ' + str(e.reason))
            elif hasattr(e, 'code'):
                API.log('The server couldn\'t fulfill the request. Error code: ' + str(e.code))
        sleep(30)
    else:
        API.halt('Can not send an request to server')

Exeption:

We failed to reach a server. 
Reason: [Errno 1] Unmapped exception: java.lang.NullPointerException
Got this failure java.lang.NullPointerException during SSL handshake (<_realsocket at 0x9d type=client open_count=1 channel=[id: 0xda3c990d, /my ip  => to ip] timeout=60.0>)

最有趣的是,这不是常数,只有jython 2.7,在Jython 2.5中正常工作

0 个答案:

没有答案