我有这个代码:
try:
self.client.post(url, data, self.cookies, headers, auth, jsonrpc)
self.status = self.client.status
self.mytime = self.client.time
self.text = self.client.text
self.length = len(self.text)
except urllib2.URLError, error:
print error
self.exception = True
self.urrlib2 = True
if isinstance(error.reason, socket.timeout):
self.timeout = True
但有时我会打印出这样的异常:
URLError in POST > reason=The read operation timed out > <urlopen error The read operation timed out>
这些由except urllib2.URLError
. 他们应该通过if isinstance(error.reason, socket.timeout)
测试,但他们没有。
所以我想知道instance
这个异常是什么。我怎样才能做到这一点?