1

我的代码:

@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')

例外:

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 中可以正常工作

4

0 回答 0